FluentCassandra.Types.CassandraType.CreateInstance C# (CSharp) Method

CreateInstance() public method

public CreateInstance ( ) : CassandraObject
return CassandraObject
        public CassandraObject CreateInstance()
        {
            if (_type == null)
                Init();

            CassandraObject obj;

            if (_type == typeof(CompositeType))
                obj = new CompositeType(_compositeTypes);
            else if (_type == typeof(DynamicCompositeType))
                obj = new DynamicCompositeType(_dynamicCompositeType);
            else
                obj = Activator.CreateInstance(_type) as CassandraObject;

            if (obj == null)
                return null;

            return obj;
        }

Usage Example

Exemplo n.º 1
0
        public static CassandraObject GetCassandraObjectFromObject(object obj, CassandraType cassandraType = null)
        {
            if (cassandraType == null)
            {
                var sourceType = obj.GetType();
                cassandraType = CassandraType.GetCassandraType(sourceType);
            }

            if (obj == null)
            {
                return(null);
            }

            if (obj is CassandraObject)
            {
                return(((CassandraObject)obj).GetValue(cassandraType));
            }

            var type = cassandraType.CreateInstance();

            if (type == null)
            {
                return(null);
            }

            type.SetValue(obj);
            return(type);
        }
All Usage Examples Of FluentCassandra.Types.CassandraType::CreateInstance