Exemplo n.º 1
0
        protected void InitLatLonNonUnique()
        {
            SemanticTypeStruct sts = Helpers.CreateSemanticType("LatLon", false, decls, structs);

            Helpers.CreateNativeType(sts, "latitude", "double", false);
            Helpers.CreateNativeType(sts, "longitude", "double", false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Associates an ST as a sub-element of the specified parent ST (sts).
 /// </summary>
 public static void CreateSemanticElement(SemanticTypeStruct sts, string subtypeName, bool unique)
 {
     sts.SemanticElements.Add(new Clifton.SemanticTypeSystem.SemanticElement()
     {
         Name = subtypeName, UniqueField = unique
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a native type for the specified ST (sts).
 /// </summary>
 public static void CreateNativeType(SemanticTypeStruct sts, string name, string type, bool unique)
 {
     sts.NativeTypes.Add(new Clifton.SemanticTypeSystem.NativeType()
     {
         Name = name, ImplementingType = type, UniqueField = unique
     });
 }
Exemplo n.º 4
0
        public static void InitializeNoun(STS ssys, List <SemanticTypeDecl> decls, List <SemanticTypeStruct> structs)
        {
            // Reflective noun necessary for self-referential definition.
            SemanticTypeDecl decl = new SemanticTypeDecl()
            {
                OfTypeName = "Noun"
            };

            decl.AttributeValues.Add(new AttributeValue()
            {
                Name = "Name", Value = "Noun"
            });
            decls.Add(decl);

            SemanticTypeStruct sts = new SemanticTypeStruct()
            {
                DeclTypeName = "Noun"
            };

            sts.NativeTypes.Add(new Clifton.SemanticTypeSystem.NativeType()
            {
                Name = "Name", ImplementingType = "string"
            });
            structs.Add(sts);
        }
Exemplo n.º 5
0
        protected void InitRestaurantLatLonUniqueParentSTElement()
        {
            SemanticTypeStruct stsRest   = Helpers.CreateSemanticType("Restaurant", false, decls, structs);
            SemanticTypeStruct stsLatLon = Helpers.CreateSemanticType("LatLon", false, decls, structs);                                 // child ST LatLon is declared to NOT be unique.

            Helpers.CreateNativeType(stsLatLon, "latitude", "double", false);
            Helpers.CreateNativeType(stsLatLon, "longitude", "double", false);
            Helpers.CreateSemanticElement(stsRest, "LatLon", true);                                                                                             // The element LatLon in Restaurant is unique.
        }
Exemplo n.º 6
0
        protected void InitRestaurantLatLonNonUnique()
        {
            SemanticTypeStruct stsRest   = Helpers.CreateSemanticType("Restaurant", false, decls, structs);
            SemanticTypeStruct stsLatLon = Helpers.CreateSemanticType("LatLon", false, decls, structs);

            Helpers.CreateNativeType(stsLatLon, "latitude", "double", false);
            Helpers.CreateNativeType(stsLatLon, "longitude", "double", false);
            Helpers.CreateSemanticElement(stsRest, "LatLon", false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Used for testing joins between two ST's that share a common unique ST.
        /// </summary>
        protected void InitFeedUrlWithUniqueStruct()
        {
            SemanticTypeStruct stsUrl = Helpers.CreateSemanticType("Url", true, decls, structs);

            Helpers.CreateNativeType(stsUrl, "Value", "string", false);

            SemanticTypeStruct stsVisited = Helpers.CreateSemanticType("Visited", false, decls, structs);

            Helpers.CreateSemanticElement(stsVisited, "Url", false);
            Helpers.CreateNativeType(stsVisited, "Count", "int", false);

            SemanticTypeStruct stsFeedUrl = Helpers.CreateSemanticType("RSSFeedUrl", false, decls, structs);

            Helpers.CreateSemanticElement(stsFeedUrl, "Url", false);
        }
Exemplo n.º 8
0
        protected void InitPersonStruct()
        {
            SemanticTypeStruct stsText = Helpers.CreateSemanticType("Text", false, decls, structs);

            Helpers.CreateNativeType(stsText, "Value", "string", false);

            SemanticTypeStruct stsFirstName = Helpers.CreateSemanticType("FirstName", false, decls, structs);

            Helpers.CreateSemanticElement(stsFirstName, "Text", false);

            SemanticTypeStruct stsLastName = Helpers.CreateSemanticType("LastName", false, decls, structs);

            Helpers.CreateSemanticElement(stsLastName, "Text", false);

            SemanticTypeStruct stsPerson = Helpers.CreateSemanticType("Person", false, decls, structs);

            Helpers.CreateSemanticElement(stsPerson, "LastName", false);
            Helpers.CreateSemanticElement(stsPerson, "FirstName", false);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a root semantic type.
        /// </summary>
        public static SemanticTypeStruct CreateSemanticType(string name, bool unique, List <SemanticTypeDecl> decls, List <SemanticTypeStruct> structs)
        {
            SemanticTypeDecl decl = new SemanticTypeDecl()
            {
                OfTypeName = "Noun"
            };

            decl.AttributeValues.Add(new AttributeValue()
            {
                Name = "Name", Value = name
            });
            SemanticTypeStruct sts = new SemanticTypeStruct()
            {
                DeclTypeName = name, Unique = unique
            };

            decls.Add(decl);
            structs.Add(sts);

            return(sts);
        }
Exemplo n.º 10
0
        protected void InitializeSDRTests(Action initStructs)
        {
            // Initialize the Semantic Type System.
            ssys = new STS();

            // Initialize the Receptor System
            rsys = new ReceptorsContainer(ssys);

            // Initialize declaration and structure lists.
            decls   = new List <SemanticTypeDecl>();
            structs = new List <SemanticTypeStruct>();

            // We must have a noun definition for now.
            Helpers.InitializeNoun(ssys, decls, structs);

            // We need this ST for query tests.
            SemanticTypeStruct sts = Helpers.CreateSemanticType("Query", false, decls, structs);

            Helpers.CreateNativeType(sts, "QueryText", "string", false);
            Helpers.CreateNativeType(sts, "Param0", "Object", false);

            // Initialize the Semantic Database Receptor
            sdr = new SemanticDatabase(rsys);
            sdr.DatabaseName = "test_semantic_database";
            sdr.Connect();

            // Create our semantic structure.
            initStructs();

            // Instantiate the runtime code-behind.
            ssys.Parse(decls, structs);
            string code = ssys.GenerateCode();

            System.Reflection.Assembly assy = Compiler.Compile(code);
            ssys.CompiledAssembly = assy;
        }