Exemple #1
0
        public static Reference ToReference_V1_0(this EnvironmentReference_V1_0 environmentReference)
        {
            if (environmentReference == null)
            {
                return(null);
            }

            if (environmentReference?.Keys?.Count > 0)
            {
                return(new Reference(environmentReference.Keys.ConvertAll(c => c.ToKey()).ToArray()));
            }
            return(null);
        }
Exemple #2
0
        public static Reference <T> ToReference_V1_0 <T>(this EnvironmentReference_V1_0 environmentReference) where T : IReferable
        {
            if (environmentReference == null)
            {
                return(null);
            }

            if (environmentReference?.Keys?.Count > 0)
            {
                return(new Reference <T>(environmentReference.Keys.ConvertAll(c => c.ToKey()).ToArray()));
            }
            return(null);
        }
Exemple #3
0
        public static EnvironmentReference_V1_0 ToEnvironmentReference_V1_0(this IIdentifiable identifiable)
        {
            if (identifiable.Identification == null)
            {
                return(null);
            }

            KeyElements_V1_0 type;

            if (identifiable is IAsset)
            {
                type = KeyElements_V1_0.Asset;
            }
            else if (identifiable is IAssetAdministrationShell)
            {
                type = KeyElements_V1_0.AssetAdministrationShell;
            }
            else if (identifiable is IConceptDescription)
            {
                type = KeyElements_V1_0.ConceptDescription;
            }
            else if (identifiable is ISubmodel)
            {
                type = KeyElements_V1_0.Submodel;
            }
            else
            {
                return(null);
            }

            EnvironmentReference_V1_0 reference = new EnvironmentReference_V1_0()
            {
                Keys = new List <EnvironmentKey_V1_0>()
                {
                    new EnvironmentKey_V1_0()
                    {
                        IdType = (KeyType_V1_0)Enum.Parse(typeof(KeyType_V1_0), identifiable.Identification.IdType.ToString()),
                        Local  = true,
                        Value  = identifiable.Identification.Id,
                        Type   = type
                    }
                }
            };

            return(reference);
        }