Example #1
0
        public AddMappingDialog(BindingList<KeyMapping> mappings, ClassDefinition acls, ClassDefinition rcls)
            : this()
        {
            _mappings = mappings;

            lblClass.Text = rcls.QualifiedName;
            lblAssocClass.Text = acls.QualifiedName;

            List<DataPropertyDefinition> aprops = new List<DataPropertyDefinition>();
            List<DataPropertyDefinition> rprops = new List<DataPropertyDefinition>();

            foreach (PropertyDefinition p in acls.Properties)
            {
                if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                    aprops.Add((DataPropertyDefinition)p);
            }

            foreach (PropertyDefinition p in rcls.Properties)
            {
                if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                    rprops.Add((DataPropertyDefinition)p);
            }

            cmbActiveProperty.DataSource = rprops;
            cmbAssociatedProperty.DataSource = aprops;

            cmbActiveProperty.SelectedIndex = 0;
            cmbAssociatedProperty.SelectedIndex = 0;
        }
Example #2
0
        public static void EqualClass(ClassDefinition classDef, ClassDefinition cd)
        {
            Assert.AreEqual(classDef.Name, cd.Name);
            Assert.AreEqual(classDef.Properties.Count, cd.Properties.Count);
            Assert.AreEqual(classDef.IdentityProperties.Count, cd.IdentityProperties.Count);
            Assert.AreEqual(classDef.ClassType, cd.ClassType);

            switch (classDef.ClassType)
            {
                case ClassType.ClassType_FeatureClass:
                    {
                        FeatureClass fc1 = classDef as FeatureClass;
                        FeatureClass fc2 = cd as FeatureClass;

                        Assert.AreEqual(fc1.GeometryProperty.Name, fc2.GeometryProperty.Name);
                    }
                    break;
            }

            foreach (PropertyDefinition propDef in classDef.Properties)
            {
                int pidx = cd.Properties.IndexOf(propDef.Name);
                Assert.IsTrue(pidx >= 0, "Could not find property named {0} in class {1}", propDef.Name, cd.Name);
                PropertyDefinition pd = cd.Properties[pidx];

                EqualProperty(propDef, pd);
            }
        }
        public FieldDefinition(string name, TypeRefDefinition type, ClassDefinition parent)
        {
            Name = name;
            Type = type;

            parent.Fields.Add(this);
        }
 public void AddClass(string name)
 {            
     for (int i = 0; i < Definitions.Count; i++)
         if (Definitions[i].name == name)
             return;
     ClassDefinition t = new ClassDefinition();
     t.name = name;
     t.props = new List<Property>();
     Definitions.Add(t);
 }
        public MethodDefinition(string name, ClassDefinition parent, int numArgs)
        {
            Name = name;
            Parent = parent;
            Parameters = new ParameterDefinition[numArgs];

            if (parent != null)
            {
                parent.Methods.Add(this);
            }
        }
        public static void WriteClassDefinition(XmlWriter writer, ClassDefinition @class)
        {
            string name = @class.GetType().Name;
            if (name.EndsWith("Definition"))
            {
                name = name.Substring(0, name.Length - "Definition".Length);
            }

            writer.WriteStartElement(name);
            writer.WriteAttributeString("Name", @class.Name);
            if (@class.NamespaceName != "")
            {
                writer.WriteAttributeString("Namespace", @class.NamespaceName);
            }

            if (@class.IsExcluded) writer.WriteAttributeString("IsExcluded", "true");
            if (@class.HasPreventDelete) writer.WriteAttributeString("HasPreventDelete", "true");
            if (@class.MarshalAsStruct) writer.WriteAttributeString("MarshalAsStruct", "true");

            foreach (var childClass in @class.NestedClasses)
            {
                WriteClassDefinition(writer, childClass);
            }

            foreach (var method in @class.Methods.Where(m => m.Access == AccessSpecifier.Public))
            {
                // Write out only methods that have non-default options
                if (method.Parameters.Any(p => p.MarshalDirection != p.Type.GetDefaultMarshalDirection()) ||
                    method.BodyText != null || method.IsExcluded)
                {
                    if (method.Field != null) continue;
                    if (method.IsConstructor && method.Parent.HidePublicConstructors) continue;

                    WriteMethodDefinition(writer, method);
                }
            }

            var classTemplate = @class as ClassTemplateDefinition;
            if (classTemplate != null)
            {
                foreach (var param in classTemplate.TemplateParameters)
                {
                    writer.WriteStartElement("TemplateParameter");
                    writer.WriteString(param);
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }
        private void ValidateBaseClass(ClassDeclaration originalDecl, ClassDefinition classDef)
        {
            if (classDef.Constructors.Any(c => !c.Symbol.IsImplicitlyDeclared) ||
                classDef.Methods.Any(m => !m.Symbol.IsImplicitlyDeclared) ||
                classDef.Properties.Any(p => p.MemberKind != MemberDefinitionKind.Field) ||
                classDef.Fields.Any(f => f.MemberKind != MemberDefinitionKind.Field))
            {
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute cannot inherit from class " + classDef.Symbol.GetFullName() +
                    ", because it contains one or more declarations that are not compatible with object literal notations.", originalDecl);
            }

            if (classDef.BaseClass != null && classDef.BaseClass.Symbol.SpecialType != Roslyn.Compilers.SpecialType.System_Object)
                ValidateBaseClass(originalDecl, classDef.BaseClass);
        }
        public static void WriteClassDefinition(XmlWriter writer, ClassDefinition @class)
        {
            string name = @class.GetType().Name;
            if (name.EndsWith("Definition"))
            {
                name = name.Substring(0, name.Length - "Definition".Length);
            }

            writer.WriteStartElement(name);
            writer.WriteAttributeString("Name", @class.Name);
            if (@class.NamespaceName != "")
            {
                writer.WriteAttributeString("Namespace", @class.NamespaceName);
            }
            if (@class.IsExcluded)
            {
                writer.WriteAttributeString("IsExcluded", "true");
            }
            if (@class.HasPreventDelete)
            {
                writer.WriteAttributeString("HasPreventDelete", "true");
            }

            foreach (var childClass in @class.Classes)
            {
                WriteClassDefinition(writer, childClass);
            }

            foreach (var method in @class.Methods)
            {
                // Write out only methods that have non-default options
                if (method.Parameters.Any(p => p.MarshalDirection == MarshalDirection.Out) ||
                    method.BodyText != null || method.IsExcluded)
                {
                    WriteMethodDefinition(writer, method);
                }
            }

            writer.WriteEndElement();
        }
Example #9
0
 /// <summary>
 /// Utility method to clone a class definition
 /// </summary>
 /// <param name="cd">The class to clone.</param>
 /// <param name="ignoreDeleted">if set to <c>true</c> [ignore deleted].</param>
 /// <returns></returns>
 public static ClassDefinition CloneClass(ClassDefinition cd, bool ignoreDeleted)
 {
     ClassDefinition classDef = null;
     switch (cd.ClassType)
     {
         case ClassType.ClassType_Class:
             {
                 Class c = new Class(cd.Name, cd.Description);
                 CopyProperties(cd.Properties, c.Properties, ignoreDeleted);
                 CopyIdentityProperties(cd.IdentityProperties, c.IdentityProperties, ignoreDeleted);
                 CopyElementAttributes(cd.Attributes, c.Attributes);
                 CopyUniqueConstraints(cd.UniqueConstraints, c);
                 classDef = c;
             }
             break;
         case ClassType.ClassType_FeatureClass:
             {
                 FeatureClass sfc = (FeatureClass)cd;
                 FeatureClass fc = new FeatureClass(cd.Name, cd.Description);
                 CopyProperties(cd.Properties, fc.Properties, ignoreDeleted);
                 CopyIdentityProperties(cd.IdentityProperties, fc.IdentityProperties, ignoreDeleted);
                 if (sfc.GeometryProperty != null)
                 {
                     string geomName = sfc.GeometryProperty.Name;
                     fc.GeometryProperty = fc.Properties[fc.Properties.IndexOf(geomName)] as GeometricPropertyDefinition;
                 }
                 CopyElementAttributes(cd.Attributes, fc.Attributes);
                 CopyUniqueConstraints(cd.UniqueConstraints, fc);
                 classDef = fc;
             }
             break;
         default:
             throw new UnsupportedException(Res.GetStringFormatted("ERR_UNSUPPORTED_CLONE_CLASS_TYPE", cd.ClassType));
     }
     return classDef;
 }
Example #10
0
        private static void PrepareClass(ClassDefinition cls, ICollection<string> propNames, ICollection<string> joinProps, string prefix, string geomProp)
        {
            var props = cls.Properties;
            var remove = new List<PropertyDefinition>();

            foreach (PropertyDefinition p in props)
            {
                if (!propNames.Contains(p.Name) && !joinProps.Contains(p.Name))
                {
                    if (!string.IsNullOrEmpty(geomProp) && p.Name == geomProp)
                        continue;

                    remove.Add(p);
                }
            }
            foreach (PropertyDefinition p in remove)
            {
                props.Remove(p);
            }

            //Strip auto-generation because we want to preserve all original values (even from auto-generated properties)
            foreach (PropertyDefinition p in props)
            {
                if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                {
                    DataPropertyDefinition dp = (DataPropertyDefinition)p;
                    dp.IsAutoGenerated = false;
                }
            }

            if (!string.IsNullOrEmpty(prefix))
            {
                foreach (PropertyDefinition p in props)
                {
                    p.Name = prefix + p.Name;
                }
            }
        }
        static void ReadClassDefinition(WrapperProject project, XmlReader reader, HeaderDefinition header, ClassDefinition parent = null)
        {
            string className = reader.GetAttribute("Name");

            ClassDefinition @class;
            string classType = reader.Name;
            switch (classType)
            {
                case "Class":
                    @class = new ClassDefinition(className, header, parent);
                    break;
                case "ClassTemplate":
                    @class = new ClassTemplateDefinition(className, header, parent);
                    break;
                case "Enum":
                    @class = new EnumDefinition(className, header, parent);
                    break;
                default:
                    throw new NotImplementedException();
            }

            string namespaceName = reader.GetAttribute("Namespace");
            if (namespaceName != null)
            {
                @class.NamespaceName = namespaceName;
            }

            if ("true".Equals(reader.GetAttribute("IsExcluded")))
            {
                @class.IsExcluded = true;
            }
            if ("true".Equals(reader.GetAttribute("HasPreventDelete")))
            {
                @class.HasPreventDelete = true;
            }
            project.ClassDefinitions.Add(@class.FullyQualifiedName, @class);

            if (reader.IsEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "Class":
                        case "ClassTemplate":
                        case "Enum":
                            {
                                ReadClassDefinition(project, reader, header, @class);
                            }
                            break;
                        case "Method":
                            {
                                ReadMethodDefinition(reader, @class);
                            }
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
        }
Example #12
0
        private string[] ExecuteBaseProcedure(LengthyOperationProgressCallBack cb, IBaseLoadProcedure proc, ref bool firstExecution)
        {
            List <string> resCreatedOrUpdated = new List <string>();

            var files     = proc.SourceFile;
            int pcPerFile = (int)(100 / files.Count);
            int current   = 0;

            string root = proc.RootPath;

            if (!root.EndsWith("/")) //NOXLATE
            {
                root += "/";         //NOXLATE
            }
            string sdp = proc.SpatialDataSourcesPath;
            string lp  = proc.LayersPath;

            if (!string.IsNullOrEmpty(sdp))
            {
                if (!sdp.EndsWith("/")) //NOXLATE
                {
                    sdp += "/";         //NOXLATE
                }
            }

            if (!string.IsNullOrEmpty(lp))
            {
                if (!lp.EndsWith("/")) //NOXLATE
                {
                    lp += "/";         //NOXLATE
                }
            }

            string fsRoot    = (string.IsNullOrEmpty(sdp) ? root : sdp) + proc.SpatialDataSourcesFolder;
            string layerRoot = (string.IsNullOrEmpty(lp) ? root : lp) + proc.LayersFolder;

            if (!fsRoot.EndsWith("/"))    //NOXLATE
            {
                fsRoot += "/";            //NOXLATE
            }
            if (!layerRoot.EndsWith("/")) //NOXLATE
            {
                layerRoot += "/";         //NOXLATE
            }
            List <string> resToUpdate = new List <string>();

            if (proc.ResourceId != null && proc.ResourceId.Count > 0)
            {
                resToUpdate.AddRange(proc.ResourceId);
                firstExecution = false;
            }
            else
            {
                firstExecution = true;
            }

            foreach (string file in files)
            {
                bool success = false;
                if (System.IO.File.Exists(file))
                {
                    //GOTCHA: We are assuming these SDF files are not SDF2 files. This is
                    //because there is no multi-platform solution to convert SDF2 files to SDF3

                    string resName  = System.IO.Path.GetFileNameWithoutExtension(file);
                    string dataName = System.IO.Path.GetFileName(file);
                    string dsId     = fsRoot + resName + ".DrawingSource";      //NOXLATE
                    string fsId     = fsRoot + resName + ".FeatureSource";      //NOXLATE
                    string lyrId    = layerRoot + resName + ".LayerDefinition"; //NOXLATE

                    if (proc.GenerateSpatialDataSources)
                    {
                        //Skip only if we have an update list and this resource id is not in it
                        bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(fsId));
                        if (!skip)
                        {
                            if (proc.Type == LoadType.Dwf)
                            {
                                //Process is as follows:
                                //
                                // 1. Create and save drawing source document.
                                // 2. Upload dwf file as resource data for this document.

                                //Step 1: Create and save drawing source document.
                                IDrawingSource ds = ObjectFactory.CreateDrawingSource();
                                ds.SourceName      = dataName;
                                ds.CoordinateSpace = proc.CoordinateSystem;
                                ds.ResourceID      = dsId;
                                this.Parent.ResourceService.SaveResource(ds);
                                resCreatedOrUpdated.Add(dsId);
                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, dsId), current));

                                //Step 2: Load resource data for document
                                this.Parent.ResourceService.SetResourceData(dsId, dataName, ResourceDataType.File, System.IO.File.OpenRead(file));
                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateLoaded, file), current));

                                ds.RegenerateSheetList(this.Parent);
                                this.Parent.ResourceService.SaveResource(ds);
                                ds.UpdateExtents(this.Parent);
                                this.Parent.ResourceService.SaveResource(ds);
                            }
                            else
                            {
                                //Process is as follows:
                                //
                                // 1. Create and save feature source document.
                                // 2. Upload sdf file as resource data for this document.
                                // 3. Test the connection, it should check out.
                                // 4. If no spatial contexts are detected, assign a default one from the load procedure and save the modified feature source.

                                //Step 1: Create feature source document
                                string provider = "OSGeo.SDF"; //NOXLATE

                                switch (proc.Type)
                                {
                                case LoadType.Sqlite:
                                    provider = "OSGeo.SQLite";     //NOXLATE
                                    break;
                                }
                                var conp = new NameValueCollection();
                                conp["File"] = StringConstants.MgDataFilePath + dataName;
                                var fs = ObjectFactory.CreateFeatureSource(provider, conp);
                                fs.ResourceID = fsId;

                                this.Parent.ResourceService.SaveResource(fs);
                                resCreatedOrUpdated.Add(fsId);
                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, fsId), current));

                                //TODO: When the infrastructure is available to us (ie. A portable .net FDO/MG Feature Service API wrapper)
                                //Maybe then we can actually implement the generalization and duplicate record handling properties. Until then, we skip
                                //these options

                                //Step 2: Load resource data for document
                                this.Parent.ResourceService.SetResourceData(fsId, dataName, ResourceDataType.File, System.IO.File.OpenRead(file));

                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, file), current));

                                //Step 3: Test to make sure we're all good so far
                                string result = this.Parent.FeatureService.TestConnection(fsId);

                                //LocalNativeConnection returns this string, so I'm assuming this is the "success" result
                                if (result == "No errors" || result.ToLower() == "true") //NOXLATE
                                {
                                    //Step 4: Test to see if default cs needs to be specified
                                    FdoSpatialContextList spatialContexts = this.Parent.FeatureService.GetSpatialContextInfo(fsId, false);
                                    if (!string.IsNullOrEmpty(proc.CoordinateSystem))
                                    {
                                        //Case 1: No spatial contexts. Register one using SupplementalContextInfo
                                        if (spatialContexts.SpatialContext.Count == 0)
                                        {
                                            //Register the default CS from the load procedure
                                            fs.AddSpatialContextOverride(new OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0.SpatialContextType()
                                            {
                                                Name             = "Default", //NOXLATE
                                                CoordinateSystem = proc.CoordinateSystem
                                            });

                                            //Update this feature source
                                            this.Parent.ResourceService.SaveResource(fs);

                                            cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateSetSpatialContext, fsId), current));
                                        }
                                        else if (spatialContexts.SpatialContext.Count == 1) //Case 2: One spatial context, but its WKT is blank. Override using SupplementalContextInfo
                                        {
                                            var sc = spatialContexts.SpatialContext[0];
                                            if (string.IsNullOrEmpty(sc.CoordinateSystemWkt))
                                            {
                                                //Register the default CS from the load procedure
                                                fs.AddSpatialContextOverride(new OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0.SpatialContextType()
                                                {
                                                    Name             = sc.Name,
                                                    CoordinateSystem = proc.CoordinateSystem
                                                });

                                                //Update this feature source
                                                this.Parent.ResourceService.SaveResource(fs);

                                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateSetSpatialContext, fsId), current));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (proc.GenerateLayers)
                    {
                        //Skip only if we have an update list and this resource id is not in it
                        bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(lyrId));
                        if (!skip)
                        {
                            if (proc.Type == LoadType.Dwf)
                            {
                                //Process is as follows
                                //
                                // 1. Enumerate the sheets on the drawing source
                                // 2. Set the referenced sheet to the first known sheet

                                var dwSvc = (IDrawingService)Parent.GetService((int)ServiceType.Drawing);
                                var list  = dwSvc.EnumerateDrawingSections(dsId);
                                if (list.Section.Count > 0)
                                {
                                    //Create drawing layer
                                    var ld = ObjectFactory.CreateDefaultLayer(LayerType.Drawing, new Version(1, 0, 0));
                                    var dl = ld.SubLayer as IDrawingLayerDefinition;
                                    dl.ResourceId = dsId;
                                    //Use the first one
                                    dl.Sheet = list.Section[0].Name;

                                    ld.ResourceID = lyrId;

                                    this.Parent.ResourceService.SaveResource(ld);
                                    resCreatedOrUpdated.Add(lyrId);
                                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, lyrId), current));
                                }
                            }
                            else
                            {
                                //NOTE: Because we are working against 1.0.0 object types this will always create 1.0.0 Layer Definition
                                //resources

                                //Process is as follows
                                //
                                // 1. Describe the schema of the feature source
                                // 2. If it contains at least one feature class, create a layer definition
                                // 3. Set the following layer definition properties:
                                //    - Feature Source: the feature source id
                                //    - Feature Class: the first feature class in the schema
                                //    - Geometry: the first geometry property in the first feature class
                                // 4. Infer the supported geometry types for this feature class. Toggle supported styles accordingly.

                                //Step 1: Describe the schema
                                //
                                //NOTE: I think we can get away with the full schema walk here. It's very unlikely we will be uploading a flat
                                //file with hundreds of classes. Even then, flat-file schema walk performance blows RDBMS walking performance
                                //out of the water anyway.
                                FeatureSourceDescription desc = this.Parent.FeatureService.DescribeFeatureSource(fsId);

                                if (desc.HasClasses())
                                {
                                    //Step 2: Find the first feature class with a geometry property
                                    ClassDefinition             clsDef = null;
                                    GeometricPropertyDefinition geom   = null;

                                    bool done = false;

                                    foreach (ClassDefinition cls in desc.AllClasses)
                                    {
                                        if (done)
                                        {
                                            break;
                                        }

                                        foreach (PropertyDefinition prop in cls.Properties)
                                        {
                                            if (done)
                                            {
                                                break;
                                            }

                                            if (prop.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Geometry)
                                            {
                                                clsDef = cls;
                                                geom   = (GeometricPropertyDefinition)prop;
                                                done   = true;
                                            }
                                        }
                                    }

                                    if (clsDef != null && geom != null)
                                    {
                                        var ld = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));

                                        //Step 3: Assign default properties
                                        ld.ResourceID = lyrId;
                                        var vld = ld.SubLayer as IVectorLayerDefinition;
                                        vld.ResourceId  = fsId;
                                        vld.FeatureName = clsDef.QualifiedName;
                                        vld.Geometry    = geom.Name;

                                        //Step 4: Infer geometry storage support and remove unsupported styles
                                        var geomTypes = geom.GetIndividualGeometricTypes();
                                        var scale     = vld.GetScaleRangeAt(0);

                                        var remove = new List <string>();
                                        if (Array.IndexOf(geomTypes, FeatureGeometricType.Point) < 0)
                                        {
                                            remove.Add(FeatureGeometricType.Point.ToString().ToLower());
                                        }
                                        if (Array.IndexOf(geomTypes, FeatureGeometricType.Curve) < 0)
                                        {
                                            remove.Add(FeatureGeometricType.Curve.ToString().ToLower());
                                        }
                                        if (Array.IndexOf(geomTypes, FeatureGeometricType.Surface) < 0)
                                        {
                                            remove.Add(FeatureGeometricType.Surface.ToString().ToLower());
                                        }

                                        scale.RemoveStyles(remove);

                                        this.Parent.ResourceService.SaveResource(ld);
                                        resCreatedOrUpdated.Add(lyrId);
                                        cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, lyrId), current));
                                    }
                                }
                            }
                        }
                    }
                    success = true;
                }
                else
                {
                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateFileNotFound, file), current));
                }

                //This file is now fully processed, so increment progress
                current += pcPerFile;

                if (success)
                {
                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateFileProcessed, file), current));
                }
            }
            return(resCreatedOrUpdated.ToArray());
        }
Example #13
0
 protected internal virtual T Visit(ClassDefinition node)
 {
     return(Visit(node as Expression));
 }
        public void ImportDefinitions(TreeNode Root)
        {
            int count = Root.Nodes.Count;
            Definitions = new List<ClassDefinition>();
            for (int i = 0; i < count; i++)
            {
                TreeNode n1 = Root.Nodes[i];
                ClassDefinition t = new ClassDefinition();
                t.name = n1.Text;
                t.props = new List<Property>();
                for (int j = 0; j < n1.Nodes.Count; j++)
                {
                    Property p = new Property();
                    TreeNode n2 = n1.Nodes[j];
                    p.name = n2.Text;
                    p.Meta = new List<PropertyMeta>();
                    for (int k = 0; k < n2.Nodes.Count / 2 ; k++)
                    {
                        TreeNode s1 = n2.Nodes[k * 2];
                        TreeNode t1 = n2.Nodes[k * 2 + 1];
                        PropertyMeta m = new PropertyMeta();
                        m.size = Convert.ToInt32(s1.Text);
                        m.type = Convert.ToInt32(t1.Text);
                        p.Meta.Add(m);
                    }
                    t.props.Add(p);
                }
                Definitions.Add(t);
            }
            bool run=true;
            while (run)
            {
                run = false;
                for (int i = 0; i < Definitions.Count - 1; i++)
                    if (string.Compare(Definitions[i].name, Definitions[i + 1].name) > 0)
                    {
                        run = true;
                        ClassDefinition t = Definitions[i];
                        Definitions[i] = Definitions[i + 1];
                        Definitions[i + 1] = t;
                    }
                for (int i = 0; i < Definitions.Count - 1; i++)
                    for(int j=0;j<Definitions[i].props.Count-1;j++)
                        if (string.Compare(Definitions[i].props[j].name, Definitions[i].props[j + 1].name) > 0)
                        {
                            run=true;
                            Property p = Definitions[i].props[j];
                            Definitions[i].props[j] = Definitions[i].props[j + 1];
                            Definitions[i].props[j + 1] = p;
                        }

            }
        }
Example #15
0
        internal static PropertyDefinition CreatePropertyFromExpressionType(string exprText, ClassDefinition clsDef, FunctionDefinitionCollection functionDefs, string defaultSpatialContextName)
        {
            string name = string.Empty;
            using (var expr = Expression.Parse(exprText))
            {
                var et = expr.GetType();
                if (typeof(ComputedIdentifier).IsAssignableFrom(et))
                {
                    var subExpr = ((ComputedIdentifier)expr).Expression;
                    return CreatePropertyFromExpressionType(subExpr.ToString(), clsDef, functionDefs, defaultSpatialContextName);
                }
                else if (typeof(Identifier).IsAssignableFrom(et))
                {
                    var id = (Identifier)expr;
                    return CloneProperty(clsDef.Properties[id.Name]);
                }
                else if (typeof(Function).IsAssignableFrom(et))
                {
                    var func = (Function)expr;
                    if (functionDefs != null)
                    {
                        var fidx = functionDefs.IndexOf(func.Name);
                        if (fidx >= 0)
                        {
                            var funcDef = functionDefs[fidx];
                            switch (funcDef.ReturnPropertyType)
                            {
                                case PropertyType.PropertyType_DataProperty:
                                    {
                                        var dp = new DataPropertyDefinition(name, "");
                                        dp.DataType = funcDef.ReturnType;
                                        dp.Nullable = true;
                                        if (dp.DataType == DataType.DataType_String)
                                            dp.Length = 255;

                                        return dp;
                                    }
                                    break;
                                case PropertyType.PropertyType_GeometricProperty:
                                    {
                                        var geom = new GeometricPropertyDefinition(name, "");
                                        geom.SpatialContextAssociation = defaultSpatialContextName;
                                        geom.GeometryTypes = (int)GeometricType.GeometricType_All;

                                        return geom;
                                    }
                                    break;

                            }
                        }
                    }
                }
                else if (typeof(BinaryExpression).IsAssignableFrom(et))
                {
                    var dp = new DataPropertyDefinition(name, "");
                    dp.DataType = DataType.DataType_Boolean;
                    dp.Nullable = true;

                    return dp;
                }
                else if (typeof(DataValue).IsAssignableFrom(et))
                {
                    var dv = (DataValue)expr;
                    var dp = new DataPropertyDefinition(name, "");
                    dp.DataType = dv.DataType;
                    if (dp.DataType == DataType.DataType_String)
                        dp.Length = 255;

                    dp.Nullable = true;
                    return dp;
                }
                else if (typeof(GeometryValue).IsAssignableFrom(et))
                {
                    var geom = new GeometricPropertyDefinition(name, "");
                    geom.GeometryTypes = (int)GeometricType.GeometricType_All;

                    return geom;
                }
            }
            return null;
        }
Example #16
0
        /// <summary>
        /// Validates the given FDO filter
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="cls"></param>
        /// <param name="caps"></param>
        public void ValidateFilter(FdoFilter filter, ClassDefinition cls, IFdoProviderCapabilities caps)
        {
            switch (filter.FilterType)
            {
            case FilterType.BinaryLogicalOperator:
            {
                var binOp = (FdoBinaryLogicalOperator)filter;
                ValidateFilter(binOp.Left, cls, caps);
                ValidateFilter(binOp.Right, cls, caps);
            }
            break;

            case FilterType.ComparisonCondition:
            {
                var compCond = (FdoComparisonCondition)filter;
                if (compCond.Operator != ComparisonOperations.Like)
                {
                    if (!caps.Filter.ConditionTypes.Select(o => o.ToUpper()).Contains("COMPARISON"))         //NOXLATE
                    {
                        throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedConditionType, compCond.Operator), compCond.Operator.ToString());
                    }
                }
                else         //Like
                {
                    if (!caps.Filter.ConditionTypes.Select(o => o.ToUpper()).Any(o => o == compCond.Operator.ToString().ToUpper()))
                    {
                        throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedConditionType, compCond.Operator), compCond.Operator.ToString());
                    }
                }
                ValidateExpression(compCond.Left, cls, caps);
                ValidateExpression(compCond.Right, cls, caps);
            }
            break;

            case FilterType.DistanceCondition:
            {
                var distCond = (FdoDistanceCondition)filter;
                if (!caps.Filter.DistanceOperations.Select(o => o.ToUpper()).Any(o => o == distCond.Operator.ToString().ToUpper()))
                {
                    throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedDistanceOperator, distCond.Operator), distCond.Operator.ToString());
                }
                ValidateIdentifier(distCond.Identifier, cls);
                ValidateExpression(distCond.Expression, cls, caps);
            }
            break;

            case FilterType.InCondition:
            {
                if (!caps.Filter.ConditionTypes.Select(o => o.ToUpper()).Contains("IN"))                                                  //NOXLATE
                {
                    throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedConditionType, "IN"), "IN"); //NOXLATE
                }
                var inCond = (FdoInCondition)filter;
                ValidateIdentifier(inCond.Identifier, cls);
                foreach (var val in inCond.ValueList)
                {
                    ValidateExpression(val, cls, caps);
                }
            }
            break;

            case FilterType.NullCondition:
            {
                if (!caps.Filter.ConditionTypes.Select(o => o.ToUpper()).Contains("NULL"))                                                    //NOXLATE
                {
                    throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedConditionType, "NULL"), "NULL"); //NOXLATE
                }
                var nullCond = (FdoNullCondition)filter;
                ValidateIdentifier(nullCond.Identifier, cls);
            }
            break;

            case FilterType.SpatialCondition:
            {
                var spFilter = (FdoSpatialCondition)filter;
                if (!caps.Filter.ConditionTypes.Select(o => o.ToUpper()).Contains("SPATIAL"))                                                                          //NOXLATE
                {
                    throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedConditionType, "SPATIAL"), spFilter.Operator.ToString()); //NOXLATE
                }
                if (!caps.Filter.SpatialOperations.Select(o => o.ToUpper()).Any(o => o == spFilter.Operator.ToString().ToUpper()))
                {
                    throw new FdoExpressionValidationException(string.Format(Strings.InvalidFilterUnsupportedSpatialOperator, spFilter.Operator), spFilter.Operator.ToString());
                }

                ValidateIdentifier(spFilter.Identifier, cls);
                ValidateExpression(spFilter.Expression, cls, caps);
            }
            break;

            case FilterType.UnaryLogicalOperator:
            {
                var negatedFilter = ((FdoUnaryLogicalOperator)filter).NegatedFilter;
                ValidateFilter(negatedFilter, cls, caps);
            }
            break;
            }
        }
 private static CompletionItem ToOverrideCompletionItem(IPythonFunctionOverload o, ClassDefinition cd, CompletionContext context, string indent)
 {
     return(new CompletionItem {
         label = o.Name,
         insertText = MakeOverrideCompletionString(indent, o, cd.Name, context),
         insertTextFormat = InsertTextFormat.PlainText,
         kind = CompletionItemKind.Method
     });
 }
Example #18
0
 public override void OnClassDefinition(ClassDefinition node)
 {
     CheckConstraints(node);
 }
Example #19
0
        /// <summary>
        /// Formats the header definitions, and adds a new class definition for each class entry.
        /// </summary>
        /// <param name="entireHeaderDefinitions">A header file as one string.</param>
        public ClassGenerator(string entireHeaderDefinitions)
        {
            // Preprocess the definitions, removing line breaks and tabs.
            string strippedHeaderFile = entireHeaderDefinitions.Replace("\t", "").Replace("\r", "");

            // Split the header file based on where it defines a new class.
            // Gets from the definition onwards until it hits another definition.
            List <string> definitions = Regex.Split(strippedHeaderFile, @"(?=\/\/ Class)|(?=\/\/ Enum)|(?=\/\/ ScriptStruct)").ToList();

            // First element is always empty.
            definitions.RemoveAt(0);

            List <string> classDefinitions  = new List <string>();
            List <string> enumDefinitions   = new List <string>();
            List <string> structDefinitions = new List <string>();

            // Handle each definition.
            foreach (string definition in definitions)
            {
                // Figure out which type of definition.
                if (definition.Contains("// Class"))
                {
                    classDefinitions.Add(definition);
                }
                else if (definition.Contains("// Enum"))
                {
                    enumDefinitions.Add(definition);
                }
                else if (definition.Contains("// ScriptStruct"))
                {
                    structDefinitions.Add(definition);
                }
            }

            // Hold a reference to all classes that should be native.
            List <string> nativeClasses = new List <string>();

            // Create each class.
            foreach (string definition in classDefinitions)
            {
                ClassDefinition newClass = new ClassDefinition(definition);
                this.GeneratedDefinitions.Add(newClass);

                // Update the list of native classes.
                if (newClass.IsNative)
                {
                    if (!nativeClasses.Contains(newClass.ParentClassName))
                    {
                        nativeClasses.Add(newClass.ParentClassName);
                    }
                }
            }

            // Update each native class to be marked as native.
            // Native classes must extend from native classes, but classes are only naturally marked native if they contain native properties.
            // This can't be done above as there is no guarantee that the parent class will exist when the child is made.
            foreach (string className in nativeClasses)
            {
                ClassDefinition nativeClass = this.GeneratedDefinitions.Find(predicateClass => predicateClass.Name == className);

                // Could extend from a class that isn't in the header files given.
                if (nativeClass != null)
                {
                    Logger.Info("Setting class '" + className + "' to native.");
                    nativeClass.IsNative = true;
                }
                else
                {
                    Logger.Warn("Attempted to set the class '" + className + "' to native, but no class with that name exists.");
                }
            }

            // Add each enum to the correct class.
            foreach (string definition in enumDefinitions)
            {
                EnumDefinition  newEnum     = new EnumDefinition(definition);
                ClassDefinition parentClass = GeneratedDefinitions.Find(def => def.PackageName == newEnum.PackageName && def.ClassFileName == newEnum.ClassFileName);

                // Create a new class if the parent doesn't exist.
                if (parentClass == null)
                {
                    Logger.Error("Parent class '" + newEnum.PackageName + "." + newEnum.ClassFileName + "' of enum '" + newEnum.Name + "' not found, setting as invalid.");
                    ClassDefinition invalidClass = new ClassDefinition(newEnum);
                    this.GeneratedDefinitions.Add(invalidClass);
                }
                else if (parentClass.ClassType == ClassDefinition.ClassTypes.Invalid)
                {
                    Logger.Error("Parent class '" + newEnum.PackageName + "." + newEnum.ClassFileName + "' of enum '" + newEnum.Name + "' not found, setting as invalid.");
                    parentClass.Enums.Add(newEnum);
                }
                else
                {
                    parentClass.Enums.Add(newEnum);
                }
            }

            // Add each struct to the correct class.
            foreach (string definition in structDefinitions)
            {
                StructDefinition newStruct   = new StructDefinition(definition);
                ClassDefinition  parentClass = GeneratedDefinitions.Find(def => def.PackageName == newStruct.PackageName && def.ClassFileName == newStruct.ClassFileName);

                // Create a new class if the parent doesn't exist.
                if (parentClass == null)
                {
                    Logger.Error("Parent class '" + newStruct.PackageName + "." + newStruct.ClassFileName + "' of struct '" + newStruct.Name + "' not found, setting as invalid.");
                    ClassDefinition invalidClass = new ClassDefinition(newStruct);
                    this.GeneratedDefinitions.Add(invalidClass);
                }
                else if (parentClass.ClassType == ClassDefinition.ClassTypes.Invalid)
                {
                    Logger.Error("Parent class '" + newStruct.PackageName + "." + newStruct.ClassFileName + "' of struct '" + newStruct.Name + "' not found, setting as invalid.");
                    parentClass.Structs.Add(newStruct);
                }
                else
                {
                    parentClass.Structs.Add(newStruct);
                }
            }

            // Check each class and set the extension class to native if the class is native. (Native classes can only extend native classes).
            foreach (ClassDefinition definition in this.GeneratedDefinitions)
            {
                if (definition.IsNative)
                {
                }
            }
        }
        void ImplementByRefICallableCall(
            Method call,
            InternalCallableType type,
            ClassDefinition node,
            CallableSignature signature,
            int byRefCount)
        {
            MethodInvocationExpression mie = CreateInvokeInvocation(type);

            IParameter[]        parameters = signature.Parameters;
            ReferenceExpression args       = CodeBuilder.CreateReference(call.Parameters[0]);

            InternalLocal[] temporaries = new InternalLocal[byRefCount];

            int byRefIndex = 0;

            for (int i = 0; i < parameters.Length; ++i)
            {
                SlicingExpression slice = CodeBuilder.CreateSlicing(args.CloneNode(), i);

                IParameter parameter = parameters[i];
                if (parameter.IsByRef)
                {
                    IType tempType = parameter.Type;
                    if (tempType.IsByRef)
                    {
                        tempType = tempType.GetElementType();
                    }
                    temporaries[byRefIndex] = CodeBuilder.DeclareLocal(call,
                                                                       "__temp_" + parameter.Name,
                                                                       tempType);

                    call.Body.Add(
                        CodeBuilder.CreateAssignment(
                            CodeBuilder.CreateReference(temporaries[byRefIndex]),
                            CodeBuilder.CreateCast(
                                tempType,
                                slice)));

                    mie.Arguments.Add(
                        CodeBuilder.CreateReference(
                            temporaries[byRefIndex]));

                    ++byRefIndex;
                }
                else
                {
                    mie.Arguments.Add(slice);
                }
            }

            if (TypeSystemServices.VoidType == signature.ReturnType)
            {
                call.Body.Add(mie);
                PropagateByRefParameterChanges(call, parameters, temporaries);
            }
            else
            {
                InternalLocal invokeReturnValue = CodeBuilder.DeclareLocal(call,
                                                                           "__returnValue", signature.ReturnType);
                call.Body.Add(
                    CodeBuilder.CreateAssignment(
                        CodeBuilder.CreateReference(invokeReturnValue),
                        mie));
                PropagateByRefParameterChanges(call, parameters, temporaries);
                call.Body.Add(
                    new ReturnStatement(
                        CodeBuilder.CreateReference(invokeReturnValue)));
            }
        }
Example #21
0
 public override bool Walk(ClassDefinition node)
 {
     CanComplete = false;
     return(base.Walk(node));
 }
        void CreatePropertyNodes(ClassDefinition classDef, TreeNode classNode)
        {
            //Pre-sort
            SortedList<string, PropertyDefinition> sorted = new SortedList<string, PropertyDefinition>();
            foreach (PropertyDefinition propDef in classDef.Properties)
                sorted.Add(propDef.Name, propDef);

            foreach (PropertyDefinition propDef in sorted.Values)
            {
                TreeNode propertyNode = new TreeNode();
                propertyNode.Name = propertyNode.Text = propDef.Name;
                switch (propDef.PropertyType)
                {
                    case PropertyType.PropertyType_DataProperty:
                        {
                            DataPropertyDefinition dataDef = propDef as DataPropertyDefinition;
                            propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_DATA_PROPERTY;
                            if (classDef.IdentityProperties.Contains(dataDef))
                                propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_ID_PROPERTY;
                            propertyNode.ToolTipText = string.Format("Data Type: {0}\nLength: {1}\nAuto-Generated: {2}\nRead-Only: {3}\nNullable: {4}", dataDef.DataType, dataDef.Length, dataDef.IsAutoGenerated, dataDef.ReadOnly, dataDef.Nullable);
                        }
                        break;
                    case PropertyType.PropertyType_GeometricProperty:
                        {
                            GeometricPropertyDefinition geomDef = propDef as GeometricPropertyDefinition;
                            propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_GEOM_PROPERTY;
                            propertyNode.ToolTipText = string.Format("Has Elevation: {0}\nHas Measure: {1}\nRead-Only: {2}\nGeometry Types: {3}\nSpatial Context: {4}", geomDef.HasElevation, geomDef.HasMeasure, geomDef.ReadOnly, GeomTypesAsString(geomDef.GeometryTypes), geomDef.SpatialContextAssociation);
                        }
                        break;
                    case PropertyType.PropertyType_RasterProperty:
                        {
                            RasterPropertyDefinition rastDef = propDef as RasterPropertyDefinition;
                            propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_RASTER_PROPERTY;
                            propertyNode.ToolTipText = "Raster Property";
                        }
                        break;
                    case PropertyType.PropertyType_ObjectProperty:
                        {
                            ObjectPropertyDefinition objDef = propDef as ObjectPropertyDefinition;
                            propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_OBJECT_PROPERTY;
                            propertyNode.ToolTipText = "Object Property";
                        }
                        break;
                    case PropertyType.PropertyType_AssociationProperty:
                        {
                            AssociationPropertyDefinition assocDef = propDef as AssociationPropertyDefinition;
                            propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_ASSOC_PROPERTY;
                            propertyNode.ToolTipText = "Association Property";
                        }
                        break;
                }
                classNode.Nodes.Add(propertyNode);
            }
        }
Example #23
0
 internal void AddClass(string schema, ClassDefinition cls)
 {
     var fidx = _schemas.IndexOf(schema);
     if (fidx >= 0)
     {
         _schemas[fidx].Classes.Add(cls);
         //Broadcast
         var handler = this.ClassAdded;
         if (handler != null)
             handler(cls);
     }
 }
Example #24
0
 public virtual void VisitClass(ClassDefinition userClass)
 {
     VisitChildren(userClass);
 }
Example #25
0
 /// <summary>
 /// Clones the class.
 /// </summary>
 /// <param name="cls">The CLS.</param>
 /// <returns></returns>
 public static ClassDefinition CloneClass(ClassDefinition cls)
 {
     return CloneClass(cls, false);
 }
Example #26
0
 public virtual void VisitStruct(ClassDefinition userStruct)
 {
     VisitChildren(userStruct);
 }
 // ClassDefinition
 public virtual bool Walk(ClassDefinition node)
 {
     return(true);
 }
Example #28
0
 public object ReadData(AMFReader reader, ClassDefinition classDefinition)
 {
     return(_readDataMethod(reader, classDefinition));
 }
Example #29
0
        /// <summary>
        /// Executes the operation
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public override IEnumerable<FdoRow> Execute(IEnumerable<FdoRow> rows)
        {
            //We fetch the class def here instead of the ctor as the class in question
            //may have to be created by a pre-copy operation
            _clsDef = _service.GetClassByName(this.ClassName);

            IInsert insert = null;
            using (FdoFeatureService service = _conn.CreateFeatureService())
            {
                insert = service.CreateCommand<IInsert>(CommandType.CommandType_Insert);
            }
            this.Info("Set feature class to: {0}", this.ClassName);
            insert.SetFeatureClassName(this.ClassName);
            PropertyValueCollection propVals = insert.PropertyValues;

            Prepare(propVals);
            foreach (FdoRow row in rows)
            {
                Bind(row);
                insert.Prepare();
                try
                {
                    using (IFeatureReader reader = insert.Execute())
                    {
                        reader.Close();
                    }
                }
                catch (OSGeo.FDO.Common.Exception ex)
                {
                    ex.Data["Class/Table"] = this.ClassName;
                    RaiseFailedFeatureProcessed(row, ex);
                    RePrepare(propVals);
                }
                yield return row;
            }
            insert.Dispose();
            //yield break;
        }
        private static ContextMenuStrip BuildSelectedPropertyContextMenu(ClassDefinition cd, EventHandler mapHandler, EventHandler removeMappingHandler, EventHandler autoCreateHandler)
        {
            ContextMenuStrip ctxSelectedProperty = new ContextMenuStrip();
            ctxSelectedProperty.Items.Add("Remove Mapping", ResourceService.GetBitmap("cross"), removeMappingHandler);
            ctxSelectedProperty.Items.Add(new ToolStripSeparator());
            ctxSelectedProperty.Items.Add("Map to property of same name (create if necessary)", null, autoCreateHandler);
            ctxSelectedProperty.Items.Add(new ToolStripSeparator());

            SortedList<string, ToolStripMenuItem> items = new SortedList<string, ToolStripMenuItem>();

            if (cd != null)
            {
                foreach (PropertyDefinition p in cd.Properties)
                {
                    if (p.PropertyType == PropertyType.PropertyType_DataProperty || p.PropertyType == PropertyType.PropertyType_GeometricProperty)
                    {
                        DataPropertyDefinition d = p as DataPropertyDefinition;
                        GeometricPropertyDefinition g = p as GeometricPropertyDefinition;
                        string name = p.Name;
                        string text = "Map to property: " + name;
                        Image icon = null;
                        if (d != null)
                        {
                            if (d.IsAutoGenerated || d.ReadOnly)
                                continue;

                            icon = ResourceService.GetBitmap("table");
                        }
                        else if (g != null)
                        {
                            if (g.ReadOnly)
                                continue;

                            icon = ResourceService.GetBitmap("shape_handles");
                        }
                        ToolStripMenuItem itm1 = new ToolStripMenuItem(text, icon, mapHandler);
                        itm1.Tag = name;
                        items.Add(name, itm1);
                    }
                }
            }
            foreach (ToolStripMenuItem item in items.Values)
            {
                ctxSelectedProperty.Items.Add(item);
            }
            return ctxSelectedProperty;
        }
 public override void OnClassDefinition(ClassDefinition node)
 {
     AddSymbolFor(node);
     base.OnClassDefinition(node);
 }
Example #32
0
        private string[] ExecuteShpLoadProcedure(LengthyOperationProgressCallBack cb, IShpLoadProcedure shpl, ref bool firstExecution)
        {
            List <string> resCreatedOrUpdated = new List <string>();

            var shpFiles  = shpl.SourceFile;
            int pcPerFile = (int)(100 / shpFiles.Count);
            int current   = 0;

            string root = shpl.RootPath;

            if (!root.EndsWith("/")) //NOXLATE
            {
                root += "/";         //NOXLATE
            }
            string sdp = shpl.SpatialDataSourcesPath;
            string lp  = shpl.LayersPath;

            if (!string.IsNullOrEmpty(sdp))
            {
                if (!sdp.EndsWith("/")) //NOXLATE
                {
                    sdp += "/";         //NOXLATE
                }
            }

            if (!string.IsNullOrEmpty(lp))
            {
                if (!lp.EndsWith("/")) //NOXLATE
                {
                    lp += "/";         //NOXLATE
                }
            }

            string fsRoot    = (string.IsNullOrEmpty(sdp) ? root : sdp) + shpl.SpatialDataSourcesFolder;
            string layerRoot = (string.IsNullOrEmpty(lp) ? root : lp) + shpl.LayersFolder;

            if (!fsRoot.EndsWith("/"))    //NOXLATE
            {
                fsRoot += "/";            //NOXLATE
            }
            if (!layerRoot.EndsWith("/")) //NOXLATE
            {
                layerRoot += "/";         //NOXLATE
            }
            List <string> resToUpdate = new List <string>();

            if (shpl.ResourceId != null)
            {
                resToUpdate.AddRange(shpl.ResourceId);
                firstExecution = false;
            }
            else
            {
                firstExecution = true;
            }

            Dictionary <string, List <string> > extraFiles = new Dictionary <string, List <string> >();

            //Unlike SDF, a SHP file actually consists of multiple files
            foreach (string shp in shpFiles)
            {
                if (!extraFiles.ContainsKey(shp))
                {
                    extraFiles[shp] = new List <string>();
                }
                //we want to preserve casing for everything before the extension
                string prefix = shp.Substring(0, shp.LastIndexOf(".") + 1); //NOXLATE
                extraFiles[shp].Add(prefix + "shx");                        //NOXLATE
                extraFiles[shp].Add(prefix + "dbf");                        //NOXLATE
                extraFiles[shp].Add(prefix + "idx");                        //NOXLATE
                extraFiles[shp].Add(prefix + "prj");                        //NOXLATE
                extraFiles[shp].Add(prefix + "cpg");                        //NOXLATE

                //TODO: Are we missing anything else?
            }

            foreach (string file in shpFiles)
            {
                bool success = false;
                if (System.IO.File.Exists(file))
                {
                    string resName  = System.IO.Path.GetFileNameWithoutExtension(file);
                    string dataName = System.IO.Path.GetFileName(file);

                    string fsId  = fsRoot + resName + ".FeatureSource";      //NOXLATE
                    string lyrId = layerRoot + resName + ".LayerDefinition"; //NOXLATE

                    if (shpl.GenerateSpatialDataSources)
                    {
                        //Skip only if we have an update list and this resource id is not in it
                        bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(fsId));
                        if (!skip)
                        {
                            //Process is as follows:
                            //
                            // 1. Create and save feature source document.
                            // 2. Upload sdf file as resource data for this document.
                            // 3. Test the connection, it should check out.
                            // 4. If no spatial contexts are detected, assign a default one from the load procedure and save the modified feature source.

                            //Step 1: Create feature source document
                            var conp = new NameValueCollection();
                            conp["DefaultFileLocation"] = StringConstants.MgDataFilePath + dataName; //NOXLATE
                            var fs = ObjectFactory.CreateFeatureSource("OSGeo.SHP", conp);           //NOXLATE
                            fs.ResourceID = fsId;

                            this.Parent.ResourceService.SaveResource(fs);
                            resCreatedOrUpdated.Add(fsId);
                            cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, fsId), current));

                            //TODO: When the infrastructure is available to us (ie. A portable .net FDO/MG Feature Service API wrapper)
                            //Maybe then we can actually implement the generalization and conversion properties. Until then, we skip
                            //these options

                            //Step 2: Load resource data for document
                            this.Parent.ResourceService.SetResourceData(fsId, dataName, ResourceDataType.File, System.IO.File.OpenRead(file));

                            cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateLoaded, file), current));

                            //Load supplementary files
                            foreach (string extraFile in extraFiles[file])
                            {
                                string dn = System.IO.Path.GetFileName(extraFile);
                                if (System.IO.File.Exists(extraFile))
                                {
                                    this.Parent.ResourceService.SetResourceData(fsId, dn, ResourceDataType.File, System.IO.File.OpenRead(extraFile));
                                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateLoaded, extraFile), current));
                                }
                            }

                            //Step 3: Test to make sure we're all good so far
                            string result = this.Parent.FeatureService.TestConnection(fsId);

                            if (Utility.IsSuccessfulConnectionTestResult(result))
                            {
                                //Step 4: Test to see if default cs needs to be specified
                                FdoSpatialContextList spatialContexts = this.Parent.FeatureService.GetSpatialContextInfo(fsId, false);
                                if (!string.IsNullOrEmpty(shpl.CoordinateSystem))
                                {
                                    bool hasPrj = false;
                                    //If there is no prj file, we can just upload one with the specified WKT
                                    var resData = this.Parent.ResourceService.EnumerateResourceData(fs.ResourceID);
                                    foreach (var resd in resData.ResourceData)
                                    {
                                        if (resd.Name == resName + ".prj") //NOXLATE
                                        {
                                            hasPrj = true;
                                            break;
                                        }
                                    }
                                    //Case 1: No .prj file. Most probable
                                    if (!hasPrj)
                                    {
                                        string tmp = System.IO.Path.GetTempFileName();
                                        System.IO.File.WriteAllText(tmp, shpl.CoordinateSystem);

                                        using (var fsr = System.IO.File.OpenRead(tmp))
                                        {
                                            this.Parent.ResourceService.SetResourceData(fs.ResourceID, resName + ".prj", ResourceDataType.File, fsr); //NOXLATE
                                            cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateUploadedPrj, resName), current));
                                        }

                                        try
                                        {
                                            System.IO.File.Delete(tmp);
                                        }
                                        catch { }
                                    }
                                    else if (spatialContexts.SpatialContext.Count == 0) //Case 2: No Spatial contexts. Declare one using SupplementalContextInfo
                                    {
                                        //Register the default CS from the load procedure
                                        fs.AddSpatialContextOverride(new OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0.SpatialContextType()
                                        {
                                            Name             = "Default", //NOXLATE
                                            CoordinateSystem = shpl.CoordinateSystem
                                        });

                                        //Update this feature source
                                        this.Parent.ResourceService.SaveResource(fs);

                                        cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateSetSpatialContext, fsId), current));
                                    }
                                    else if (spatialContexts.SpatialContext.Count == 1) //Case 3: One spatial context with blank WKT. Override it using the SupplementalContextInfo
                                    {
                                        var sc = spatialContexts.SpatialContext[0];
                                        if (string.IsNullOrEmpty(sc.CoordinateSystemWkt))
                                        {
                                            //Register the default CS from the load procedure
                                            fs.AddSpatialContextOverride(new OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0.SpatialContextType()
                                            {
                                                Name             = sc.Name,
                                                CoordinateSystem = shpl.CoordinateSystem
                                            });

                                            //Update this feature source
                                            this.Parent.ResourceService.SaveResource(fs);

                                            cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateSetSpatialContext, fsId), current));
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (shpl.GenerateLayers)
                    {
                        //Skip only if we have an update list and this resource id is not in it
                        bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(lyrId));
                        if (!skip)
                        {
                            //NOTE: Because we are working against 1.0.0 object types this will always create 1.0.0 Layer Definition
                            //resources

                            //Process is as follows
                            //
                            // 1. Describe the schema of the feature source
                            // 2. If it contains at least one feature class, create a layer definition
                            // 3. Set the following layer definition properties:
                            //    - Feature Source: the feature source id
                            //    - Feature Class: the first feature class in the schema
                            //    - Geometry: the first geometry property in the first feature class
                            // 4. Infer the supported geometry types for this feature class. Toggle supported styles accordingly.

                            //Step 1: Describe the schema
                            //
                            //NOTE: I think we can get away with the full schema walk here. It's very unlikely we will be uploading a flat
                            //file with hundreds of classes. Even then, flat-file schema walk performance blows RDBMS walking performance
                            //out of the water anyway.
                            FeatureSourceDescription desc = this.Parent.FeatureService.DescribeFeatureSource(fsId);

                            //Step 2: Find the first feature class with a geometry property
                            ClassDefinition             clsDef = null;
                            GeometricPropertyDefinition geom   = null;

                            bool done = false;

                            foreach (ClassDefinition cls in desc.AllClasses)
                            {
                                if (done)
                                {
                                    break;
                                }

                                foreach (PropertyDefinition prop in cls.Properties)
                                {
                                    if (done)
                                    {
                                        break;
                                    }

                                    if (prop.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Geometry)
                                    {
                                        clsDef = cls;
                                        geom   = (GeometricPropertyDefinition)prop;
                                        done   = true;
                                    }
                                }
                            }

                            if (clsDef != null && geom != null)
                            {
                                var ld = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));

                                //Step 3: Assign default properties
                                ld.ResourceID = lyrId;
                                var vld = ld.SubLayer as IVectorLayerDefinition;
                                vld.ResourceId  = fsId;
                                vld.FeatureName = clsDef.QualifiedName;
                                vld.Geometry    = geom.Name;

                                //Step 4: Infer geometry storage support and remove unsupported styles
                                var scale     = vld.GetScaleRangeAt(0);
                                var geomTypes = geom.GetIndividualGeometricTypes();
                                var remove    = new List <string>();
                                if (Array.IndexOf(geomTypes, FeatureGeometricType.Point) < 0)
                                {
                                    remove.Add(FeatureGeometricType.Point.ToString().ToLower());
                                }
                                if (Array.IndexOf(geomTypes, FeatureGeometricType.Curve) < 0)
                                {
                                    remove.Add(FeatureGeometricType.Curve.ToString().ToLower());
                                }
                                if (Array.IndexOf(geomTypes, FeatureGeometricType.Surface) < 0)
                                {
                                    remove.Add(FeatureGeometricType.Surface.ToString().ToLower());
                                }

                                scale.RemoveStyles(remove);

                                this.Parent.ResourceService.SaveResource(ld);
                                resCreatedOrUpdated.Add(lyrId);
                                cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateCreated, lyrId), current));
                            }
                        }
                    }
                    success = true;
                }
                else
                {
                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateFileNotFound, file), current));
                }

                //This file is now fully processed, so increment progress
                current += pcPerFile;

                if (success)
                {
                    cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateSuccess, file), current));
                }
            }

            return(resCreatedOrUpdated.ToArray());
        }
 public void ClassChanged()
 {
     if (_view.SelectedClass != null)
     {
         List<string> p = new List<string>();
         List<string> pg = new List<string>();
         var cls = _walker.GetClassDefinition(_view.SelectedSchema, _view.SelectedClass.ClassName);
         this.SelectedClass = cls;
         foreach (PropertyDefinition pd in cls.Properties)
         {
             if (pd.PropertyType != PropertyType.PropertyType_RasterProperty)
             {
                 if (pd.PropertyType == PropertyType.PropertyType_DataProperty || pd.PropertyType == PropertyType.PropertyType_GeometricProperty)
                 {
                     p.Add(pd.Name);
                     bool groupable = pd.PropertyType == PropertyType.PropertyType_DataProperty && ((pd as DataPropertyDefinition).DataType != DataType.DataType_CLOB && (pd as DataPropertyDefinition).DataType != DataType.DataType_BLOB);
                     if (groupable)
                         pg.Add(pd.Name);
                 }
             }
             else //Raster's can't be previewed via this approach, so disable map view
             {
                 _view.FireMapPreviewStateChanged(false);
             }
         }
         _view.PropertyList = p;
         _view.GroupableProperties = pg;
     }
 }
Example #34
0
        public override void RegisterPlug(ITransactionContext context)
        {
            Console.WriteLine("Installing AbstractUI.Treeview");
            FileTransaction trans = new FileTransaction();

            trans.BeginTransaction();

            PlugLocationFactory plugLocFactory = PlugLocationFactory.GetInstance();

            plugLocFactory.Context = context as ISqlTransactionContext;
            string EXEC_DIR = new PlugLocationController(context).LoadByName("EXECUTABLE_DIR").PlugLocationPath;

            PlugIn plug = new PlugIn();

            plug.PlugName         = "Interlogic.Trainings.Plugs.AbstractUI.TreeView";
            plug.PlugVersion      = "0.0.0.1";
            plug.PlugFriendlyName = "AbstractUI.TreeView";
            plug.PlugDescription  = "AbstractUI.TreeView Interfaces";
            plug.Active           = true;

            PlugFile file = new PlugFile();

            file.PlugFileName         = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.dll";
            file.RelativeIncomingPath = @"..\..\..\Interlogic.Trainings.Plugs.AbstractUI.TreeView\bin\Debug";
            file.DestinationPath      = "EXECUTABLE_DIR";
            plug.Files.Add(file);
            trans.AddAction(new CopyFileAction(Path.Combine(file.RelativeIncomingPath, file.PlugFileName), Path.Combine(EXEC_DIR, file.PlugFileName), true));

            file = new PlugFile();
            file.PlugFileName         = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.pdb";
            file.RelativeIncomingPath = @"..\..\..\Interlogic.Trainings.Plugs.AbstractUI.TreeView\bin\Debug";
            file.DestinationPath      = "EXECUTABLE_DIR";
            plug.Files.Add(file);
            trans.AddAction(new CopyFileAction(Path.Combine(file.RelativeIncomingPath, file.PlugFileName), Path.Combine(EXEC_DIR, file.PlugFileName), true));

            ClassDefinition classDef = new ClassDefinition();

            classDef.Active    = true;
            classDef.ClassName = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.IAbstractStartupTreeNodeProvider";
            classDef.FileName  = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.dll";
            classDef.ClassDefinitionDescription = "IAbstractStartupTreeNodeProvider public interface";
            plug.ClassDefinitions.Add(classDef);

            classDef           = new ClassDefinition();
            classDef.Active    = true;
            classDef.ClassName = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.IAbstractTreeNodeProvider";
            classDef.FileName  = "Interlogic.Trainings.Plugs.AbstractUI.TreeView.dll";
            classDef.ClassDefinitionDescription = "IAbstractTreeNodeProvider public interface";
            plug.ClassDefinitions.Add(classDef);

            try
            {
                trans.Execute();
                trans.Commit();
                PlugInController plugController = new PlugInController(context);
                plugController.InsertAll(plug);
            }
            catch (Exception e)
            {
                Console.WriteLine("AbstractUI.Treeview installation failed");
                trans.RollBack();
                throw new Exception("AbstractUI.TreeView Installation Process Failed!", e);
            }
            Console.WriteLine("AbstractUI.Treeview successfully installed");
        }
Example #35
0
            public override bool Walk(ClassDefinition node)
            {
                AddTagIfNecessary(node, node.HeaderIndex + 1, node.Decorators);

                return(base.Walk(node));
            }
Example #36
0
 internal void AddClassReference(ClassDefinition classDefinition)
 {
     _classDefinitions.Add(classDefinition);
 }
        static void ReadMethodDefinition(XmlReader reader, ClassDefinition @class)
        {
            string name = reader.GetAttribute("Name");
            string isExcluded = reader.GetAttribute("IsExcluded");

            var parameters = new List<ParameterDefinition>();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                switch (reader.Name)
                {
                    case "Parameter":
                        {
                            string parameterName = reader.GetAttribute("Name");
                            var parameter = new ParameterDefinition(parameterName, null);
                            string marshalDirectionString = reader.GetAttribute("MarshalDirection");
                            if (marshalDirectionString != null)
                            {
                                MarshalDirection marshalDirection;
                                if (Enum.TryParse(marshalDirectionString, out marshalDirection))
                                {
                                    parameter.MarshalDirection = marshalDirection;
                                }
                            }
                            parameters.Add(parameter);
                        }
                        continue;
                }
            }

            var method = new MethodDefinition(name, @class, parameters.Count);
            for (int i = 0; i < parameters.Count; i++)
            {
                method.Parameters[i] = parameters[i];
            }
            if ("true".Equals(isExcluded))
            {
                method.IsExcluded = true;
            }
        }
Example #38
0
        internal object ReadAMF3Object(ClassDefinition classDefinition)
        {
            object instance = null;

            if (!string.IsNullOrEmpty(classDefinition.ClassName))
            {
                instance = ObjectFactory.CreateInstance(classDefinition.ClassName);
            }
            else
            {
                instance = new ASObject()
                {
                    Definition = classDefinition
                }
            };
            if (instance == null)
            {
#if !SILVERLIGHT
                if (log.IsWarnEnabled)
                {
                    log.Warn(__Res.GetString(__Res.TypeLoad_ASO, classDefinition.ClassName));
                }
#endif
                instance = new ASObject(classDefinition.ClassName);
            }
            AddAMF3ObjectReference(instance);
            if (classDefinition.IsExternalizable)
            {
                if (instance is IExternalizable)
                {
                    IExternalizable externalizable = instance as IExternalizable;
                    DataInput       dataInput      = new DataInput(this);
                    externalizable.ReadExternal(dataInput);
                }
                else
                {
                    string msg = __Res.GetString(__Res.Externalizable_CastFail, instance.GetType().FullName, classDefinition.ClassName);
                    throw new FluorineException(msg);
                }
            }
            else
            {
                for (int i = 0; i < classDefinition.MemberCount; i++)
                {
                    string key   = classDefinition.Members[i].Name;
                    object value = ReadAMF3Data();
                    SetMember(instance, key, value);
                }
                if (classDefinition.IsDynamic)
                {
                    string key = ReadAMF3String();
                    while (key != null && key != string.Empty)
                    {
                        object value = ReadAMF3Data();
                        SetMember(instance, key, value);
                        key = ReadAMF3String();
                    }
                }
            }
            return(instance);
        }
Example #39
0
        private ClassDefinition CreateMergedClass(ClassDefinition leftCls, ClassDefinition rightCls)
        {
            ClassDefinition cls = null;

            if (!string.IsNullOrEmpty(_options.GeometryProperty))
                cls = new FeatureClass(_options.Target.ClassName, "");
            else
                cls = new Class(_options.Target.ClassName, "");

            var props = cls.Properties;
            foreach (PropertyDefinition p in leftCls.Properties)
            {
                int idx = props.IndexOf(p.Name);
                if (idx < 0)
                {
                    var prop = FdoSchemaUtil.CloneProperty(p);
                    props.Add(prop);
                }
            }
            foreach (PropertyDefinition p in rightCls.Properties)
            {
                int idx = props.IndexOf(p.Name);
                if (idx < 0)
                {
                    var prop = FdoSchemaUtil.CloneProperty(p);
                    props.Add(prop);
                }
            }

            //Strip off autogeneration because we want to preserve original values
            foreach (PropertyDefinition p in props)
            {
                if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                {
                    DataPropertyDefinition dp = (DataPropertyDefinition)p;
                    dp.IsAutoGenerated = false;
                }
            }

            DataPropertyDefinition fid = new DataPropertyDefinition("FID", "Autogenerated ID");
            fid.DataType = DataType.DataType_Int32;
            fid.IsAutoGenerated = true;
            fid.Nullable = false;

            props.Add(fid);
            cls.IdentityProperties.Add(fid);

            if (!string.IsNullOrEmpty(_options.GeometryProperty))
            {
                //If prefixed, we need to qualify it to match what's in the merged class
                string pn = _options.GeometryProperty;
                if (_options.Side == JoinSide.Left)
                {
                    if (!string.IsNullOrEmpty(_options.LeftPrefix))
                        pn = _options.LeftPrefix + pn;
                }
                else
                {
                    if (!string.IsNullOrEmpty(_options.RightPrefix))
                        pn = _options.RightPrefix + pn;
                }

                int idx = props.IndexOf(pn);
                if (idx < 0)
                {
                    throw new FdoETLException("Property not found in merged class: " + _options.GeometryProperty);
                }
                else
                {
                    var p = props[idx];
                    if (p.PropertyType != PropertyType.PropertyType_GeometricProperty)
                        throw new FdoETLException("Designated property is not a geometry property: " + _options.GeometryProperty);

                    ((FeatureClass)cls).GeometryProperty = (GeometricPropertyDefinition)p;
                }
            }

            return cls;
        }
Example #40
0
        /// <summary>
        /// Adds the namespace to the class name taken from the class definition.
        /// </summary>
        void GetFullyQualifiedName(ClassDefinition classDefinition)
        {
            string ns = CompilationUnit.UsingScope.NamespaceName;

            FullyQualifiedName = String.Format("{0}.{1}", ns, classDefinition.Name);
        }
        private void UpdateClassNode(TreeNode classNode, ClassDefinition classDef)
        {
            if (classNode.Level != NODE_LEVEL_CLASS)
                return;

            classNode.Nodes.Clear();
            classNode.Name = classNode.Text = classDef.Name;
            classNode.ContextMenuStrip = _explorer.GetContextMenu(NODE_CLASS);
            classNode.ImageKey = classNode.SelectedImageKey = (classDef.ClassType == ClassType.ClassType_FeatureClass ? IMG_FEATURE_CLASS : IMG_CLASS);
            classNode.ToolTipText = string.Format("Type: {0}\nIsAbstract: {1}\nIsComputed: {2}\nBase Class: {3}\nUnique Constraints: {4}",
                classDef.ClassType,
                classDef.IsAbstract,
                classDef.IsComputed,
                classDef.BaseClass != null ? classDef.BaseClass.Name : "(none)",
                GetUniqueConstraintString(classDef.UniqueConstraints));
            classNode.Tag = false; //Is not partial
            CreatePropertyNodes(classDef, classNode);
        }
Example #42
0
 void GetClassRegions(ClassDefinition classDefinition)
 {
     GetRegion(classDefinition);
     BodyRegion = PythonMethodOrClassBodyRegion.GetBodyRegion(classDefinition);
 }
Example #43
0
 internal void DeleteClass(ClassDefinition classDefinition)
 {
     classDefinition.Delete();
     var handler = this.ClassRemoved;
     if (handler != null)
         handler(classDefinition);
 }
Example #44
0
 public void SetUp()
 {
     _classDefinition           = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Order));
     _invalidEndPointDefinition = new InvalidRelationEndPointDefinitionBase(_classDefinition, "TestProperty", typeof(string));
 }
Example #45
0
        private static ICollection<string> GetReferencedClasses(ClassDefinition clsDef)
        {
            HashSet<string> clsNames = new HashSet<string>();

            foreach (PropertyDefinition propDef in clsDef.Properties)
            {
                if (propDef.PropertyType == PropertyType.PropertyType_AssociationProperty)
                {
                    AssociationPropertyDefinition ap = (AssociationPropertyDefinition)propDef;
                    clsNames.Add(ap.AssociatedClass.QualifiedName);
                }
                else if (propDef.PropertyType == PropertyType.PropertyType_ObjectProperty)
                {
                    ObjectPropertyDefinition op = (ObjectPropertyDefinition)propDef;
                    clsNames.Add(op.Class.QualifiedName);
                }
            }

            return clsNames;
        }
Example #46
0
 public override void OnClassDefinition(ClassDefinition node)
 {
     ConvertTypeDefinition(node).IsClass = true;
 }
Example #47
0
        /// <summary>
        /// Utility method to copy all unique constraints of a class
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        private static void CopyUniqueConstraints(UniqueConstraintCollection source, ClassDefinition target)
        {
            if (source.Count == 0)
                return;

            var props = target.Properties;
            foreach (UniqueConstraint uniq in source)
            {
                var ucs = new UniqueConstraint();
                foreach (DataPropertyDefinition dp in uniq.Properties)
                {
                    if (props.Contains(dp.Name))
                    {
                        var prop = props[dp.Name];
                        if (prop.PropertyType == PropertyType.PropertyType_DataProperty)
                            ucs.Properties.Add((DataPropertyDefinition)prop);
                    }
                }
                target.UniqueConstraints.Add(ucs);
            }
        }
Example #48
0
 public override void OnClassDefinition(ClassDefinition node)
 {
     node.Name = node.Name.TrimStart('@');
     base.OnClassDefinition(node);
 }
 public virtual void PostWalk(ClassDefinition node)
 {
 }
 // ClassDefinition
 public virtual bool Walk(ClassDefinition node) { return true; }
Example #51
0
 public ClassSection(ClassDefinition def)
 {
     Utils.CopyCast(def, this);
 }
 // ClassDefinition
 public override bool Walk(ClassDefinition node) { return false; }
        public void ClassChanged()
        {
            if (_view.SelectedClass != null)
            {
                var cls = _walker.GetClassDefinition(_view.SelectedSchema, _view.SelectedClass.ClassName);
                this.SelectedClass = cls;
                List<string> p = new List<string>();
                foreach (PropertyDefinition pd in cls.Properties)
                {
                    if (pd.PropertyType == PropertyType.PropertyType_DataProperty || pd.PropertyType == PropertyType.PropertyType_GeometricProperty)
						p.Add(pd.Name);
					else if (pd.PropertyType == PropertyType.PropertyType_ObjectProperty)
					{
						String szPrefix = pd.Name;
						ObjectPropertyDefinition pdo = (ObjectPropertyDefinition)pd;

						// TODO: make this an iterative loop
						// only processing one sub-set for now
		                foreach (PropertyDefinition pdSub in pdo.Class.Properties)
						{
							if (pdSub.PropertyType == PropertyType.PropertyType_DataProperty || pd.PropertyType == PropertyType.PropertyType_GeometricProperty)
								p.Add(szPrefix + "." + pdSub.Name);

							// TODO: process objects and associations
						}
					}
					else if (pd.PropertyType == PropertyType.PropertyType_AssociationProperty)
					{
						String szPrefix = pd.Name;
						AssociationPropertyDefinition pda = (AssociationPropertyDefinition)pd;

						// TODO: make this an iterative loop
						// only processing one sub-set for now
						foreach (PropertyDefinition pdSub in pda.AssociatedClass.Properties)
						{
							if (pdSub.PropertyType == PropertyType.PropertyType_DataProperty || pd.PropertyType == PropertyType.PropertyType_GeometricProperty)
								p.Add(szPrefix + "." + pdSub.Name);

							// TODO: process objects and associations
						}
					}
                }
                _view.PropertyList = p;
                _view.FireMapPreviewStateChanged(cls.ClassType == ClassType.ClassType_FeatureClass);
            }
        }
Example #54
0
 public override void PostWalk(ClassDefinition node)
 {
     PostWalkWorker(node);
 }
Example #55
0
 public override bool Walk(ClassDefinition node)
 {
     return(false);
 }
 public override void PostWalk(ClassDefinition node)
 {
 }
 public virtual void PostWalk(ClassDefinition node) { }
Example #58
0
 public override void PostWalk(ClassDefinition node)
 {
     _scopes.Add(node);
     base.PostWalk(node);
 }
 public override void PostWalk(ClassDefinition node) { }
Example #60
0
 public ReferenceModelFactory(ClassDefinition type)
 {
     this.Type      = type;
     this.NullModel = new NullReferenceModel(this);
 }