EncodeGuid() 공개 정적인 메소드

Conversion of a GUID to a string representing the GUID
public static EncodeGuid ( System.Guid guid ) : string
guid System.Guid The GUID to convert
리턴 string
예제 #1
0
        protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
        {
            IfcObjectPlacement placement    = ObjectPlacement;
            JObject            placementObj = null;

            if (placement != null)
            {
                if (string.IsNullOrEmpty(placement.mGlobalId))
                {
                    placement.setGlobalId(ParserIfc.EncodeGuid(Guid.NewGuid()));
                }
                placementObj = placement.getJson(this, options);
            }
            base.setJSON(obj, host, options);

            if (placementObj != null)
            {
                obj["ObjectPlacement"] = placementObj;
            }
            if (options.Style != SetJsonOptions.JsonStyle.Repository)
            {
                IfcProductDefinitionShape representation = Representation;
                if (representation != null)
                {
                    obj["Representation"] = representation.getJson(this, options);
                }
            }
            //internal List<IfcRelAssignsToProduct> mReferencedBy = new List<IfcRelAssignsToProduct>();//	 :	SET OF IfcRelAssignsToProduct FOR RelatingProduct;
        }
        private JObject writeRepositoryCommon(JObject obj, SetJsonOptions options, string folderName)
        {
            if (string.IsNullOrEmpty(options.ProjectFolder))
            {
                return(obj);
            }
            if (string.IsNullOrEmpty(mGlobalId))
            {
                obj["id"] = mGlobalId = ParserIfc.EncodeGuid(Guid.NewGuid());
            }
            options.Encountered.Add(mGlobalId);
            string folder = Path.Combine(options.ProjectFolder, string.IsNullOrEmpty(folderName) ?  StepClassName.Substring(3) : folderName);

            Directory.CreateDirectory(folder);
            string       path         = Path.Combine(folder, RepositoryName + ".ifc.json");
            StreamWriter streamWriter = new StreamWriter(path);

            streamWriter.Write(obj.ToString());
            streamWriter.Close();
            setFileAttributes(path, options.RepositoryAttributes);
            setFolderAttributes(folder, options.RepositoryAttributes);
            JObject result = new JObject();

            result["href"] = mGlobalId;
            return(result);
        }
예제 #3
0
        protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
        {
            base.setJSON(obj, host, options);
            if (options.Style == SetJsonOptions.JsonStyle.Repository && string.IsNullOrEmpty(mGlobalId))
            {
                mGlobalId = ParserIfc.EncodeGuid(Guid.NewGuid());
            }
            string contextIdentifier = ContextIdentifier;

            if (!string.IsNullOrEmpty(contextIdentifier))
            {
                obj["ContextIdentifier"] = contextIdentifier;
            }
            string contextType = ContextType;

            if (!string.IsNullOrEmpty(contextType))
            {
                obj["ContextType"] = contextType;
            }
            JArray reps = new JArray();

            foreach (IfcRepresentation <IfcRepresentationItem> r in RepresentationsInContext)
            {
                if (r.mOfProductRepresentation.Count == 0 && r.mRepresentationMap == null)
                {
                    reps.Add(r.getJson(this, options));
                }
            }
            if (reps.Count > 0)
            {
                obj["RepresentationsInContext"] = reps;
            }
        }
        public JObject getJson(BaseClassIfc host, SetJsonOptions options)
        {
            bool    common = isCommon;
            JObject obj    = new JObject();

            if (!string.IsNullOrEmpty(mGlobalId))
            {
                if (options.Encountered.Contains(mGlobalId))
                {
                    obj["href"] = mGlobalId;
                    return(obj);
                }
                else
                {
                    options.Encountered.Add(mGlobalId);
                }
            }
            obj["type"] = StepClassName;
            if (common || (options.SerializeAllGlobalIds && !string.IsNullOrEmpty(mGlobalId)) || this is IfcGeometricRepresentationContext || this is NamedObjectIfc)
            {
                if (string.IsNullOrEmpty(mGlobalId))
                {
                    mGlobalId = ParserIfc.EncodeGuid(Guid.NewGuid());
                    options.Encountered.Add(mGlobalId);
                }
                if (options.SerializeAllGlobalIds && !string.IsNullOrEmpty(mGlobalId))
                {
                    obj["id"] = mGlobalId;
                }
            }

            setJSON(obj, host, options);
            if (options.Style == SetJsonOptions.JsonStyle.Repository)
            {
                if (common)
                {
                    return(writeRepositoryCommon(obj, options, ""));
                }
                else
                {
                    IfcRelationship relationship = this as IfcRelationship;
                    if (relationship != null)
                    {
                        if (this is IfcRelAssociates || this is IfcRelDefinesByType)
                        {
                            return(this.writeRepositoryCommon(obj, options));
                        }
                        else
                        {
                            IfcRelDefinesByProperties properties = this as IfcRelDefinesByProperties;
                            if (properties != null && properties.RelatedObjects.Count > 1)
                            {
                                return(this.writeRepositoryCommon(obj, options));
                            }
                        }
                    }
                }
            }
            return(obj);
        }
예제 #5
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     if (options.Style == SetJsonOptions.JsonStyle.Repository && string.IsNullOrEmpty(mGlobalId))
     {
         setGlobalId(ParserIfc.EncodeGuid(Guid.NewGuid()));
         options.Encountered.Add(mGlobalId);
     }
     base.setJSON(obj, host, options);
     obj["ParentContext"] = ParentContext.getJson(this, options);
     if (!double.IsNaN(mTargetScale))
     {
         obj["TargetScale"] = mTargetScale.ToString();
     }
     obj["TargetView"] = TargetView.ToString();
     setAttribute(obj, "UserDefinedTargetView", UserDefinedTargetView);
 }
예제 #6
0
        protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
        {
            base.setJSON(obj, host, options);
            if (options.Style == SetJsonOptions.JsonStyle.Repository && string.IsNullOrEmpty(mGlobalId))
            {
                setGlobalId(ParserIfc.EncodeGuid(Guid.NewGuid()));
            }
            string contextIdentifier = ContextIdentifier;

            if (!string.IsNullOrEmpty(contextIdentifier))
            {
                obj["ContextIdentifier"] = contextIdentifier;
            }
            string contextType = ContextType;

            if (!string.IsNullOrEmpty(contextType))
            {
                obj["ContextType"] = contextType;
            }
        }