Beispiel #1
0
        internal static TSchema GetInstance <TSchema>() where TSchema : ObjectSchema, new()
        {
            ObjectSchema.SchemaConstructorDelegate schemaConstructor = () => Activator.CreateInstance <TSchema>();
            ObjectSchema instanceImpl = ObjectSchema.GetInstanceImpl(typeof(TSchema), schemaConstructor);

            return((TSchema)((object)instanceImpl));
        }
Beispiel #2
0
        internal QueryParser(string query, ObjectSchema schema, QueryParser.Capabilities capabilities, QueryParser.EvaluateVariableDelegate evalDelegate, QueryParser.ConvertValueFromStringDelegate convertDelegate)
        {
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }
            Hashtable allFilterable = new Hashtable(schema.AllFilterableProperties.Count, StringComparer.OrdinalIgnoreCase);

            foreach (PropertyDefinition propertyDefinition in schema.AllFilterableProperties)
            {
                allFilterable.Add(propertyDefinition.Name, propertyDefinition);
            }
            this.parser = new Parser(query, capabilities, (string propName) => (PropertyDefinition)allFilterable[propName], null, evalDelegate, convertDelegate);
        }
Beispiel #3
0
 internal static ObjectSchema GetInstance(Type schemaType)
 {
     if (null == schemaType)
     {
         throw new ArgumentNullException("schemaType");
     }
     if (!typeof(ObjectSchema).GetTypeInfo().IsAssignableFrom(schemaType.GetTypeInfo()))
     {
         throw new ArgumentException(string.Format("Invalid ObjectSchema Input Type: {0}", schemaType), "schemaType");
     }
     if (!ReflectionHelper.HasParameterlessConstructor(schemaType))
     {
         throw new ArgumentException(string.Format("Input type does not have a parameterless constructor: {0}", schemaType), "schemaType");
     }
     ObjectSchema.SchemaConstructorDelegate schemaConstructor = () => (ObjectSchema)Activator.CreateInstance(schemaType);
     return(ObjectSchema.GetInstanceImpl(schemaType, schemaConstructor));
 }
        internal static bool AreEqual(ConfigurableObject objA, ConfigurableObject objB)
        {
            if (objA == null || objB == null)
            {
                return(objA == null && objB == null);
            }
            if (objA.GetType() != objB.GetType())
            {
                return(false);
            }
            ObjectSchema objectSchema = objA.ObjectSchema;

            foreach (PropertyDefinition propertyDefinition in objectSchema.AllProperties)
            {
                if (!object.Equals(objA[propertyDefinition], objB[propertyDefinition]))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        private static ObjectSchema GetInstanceImpl(Type schemaType, ObjectSchema.SchemaConstructorDelegate schemaConstructor)
        {
            ObjectSchema result;

            if (!ObjectSchema.Instances.TryGetValue(schemaType, out result))
            {
                lock (ObjectSchema.InstancesLock)
                {
                    if (!ObjectSchema.Instances.TryGetValue(schemaType, out result))
                    {
                        ObjectSchema objectSchema = schemaConstructor();
                        ObjectSchema.Instances = new Dictionary <Type, ObjectSchema>(ObjectSchema.Instances)
                        {
                            {
                                schemaType,
                                objectSchema
                            }
                        };
                        result = objectSchema;
                    }
                }
            }
            return(result);
        }