예제 #1
0
        public ContextResult <Service.CRM_Person> GetUserDetails(string key, string email, string password)
        {
            ServiceDataContext db = new ServiceDataContext();

            email = email.ToLower();

            var person = db.CRM_Persons.ToList().FirstOrDefault(c => !c.IsArchived && c.PrimaryEmail.ToLower() == email && c.Password == password);

            var tempPerson = new Service.CRM_Person()
            {
                PrimaryEmail     = person.PrimaryEmail,
                Title            = person.Title,
                Firstname        = person.Firstname,
                Lastname         = person.Lastname,
                PrimaryAddressID = person.PrimaryAddressID,
            };

            ContextResult <Service.CRM_Person> result = new ContextResult <Service.CRM_Person>()
            {
                ReturnObject = tempPerson
            };

            result.IsSuccess = IsAuthValid(key);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #2
0
        public ContextResult <Service.CRM_Address> GetAddress(string key, int addressID)
        {
            ServiceDataContext db = new ServiceDataContext();

            var address = db.CRM_Addresses.ToList().FirstOrDefault(c => c.ID == addressID);

            ContextResult <Service.CRM_Address> result = new ContextResult <Service.CRM_Address>()
            {
                ReturnObject = new Service.CRM_Address()
                {
                    AddressLine1 = address.AddressLine1,
                    AddressLine2 = address.AddressLine3,
                    AddressLine3 = address.AddressLine3,
                    AddressLine4 = address.AddressLine4,
                    AddressLine5 = address.AddressLine5,
                    Town         = address.Town,
                    County       = address.County,
                    Postcode     = address.Postcode
                }
            };

            result.IsSuccess = IsAuthValid(key);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #3
0
        public ContextResult <Service.CRM_Venue[]> GetVenues(string authkey)
        {
            ServiceDataContext db = new ServiceDataContext();

            var venueList = new List <Service.CRM_Venue>();

            foreach (var source in db.CRM_Venues.ToArray())
            {
                venueList.Add(new Service.CRM_Venue()
                {
                    Name = source.Name,
                    ID   = source.ID
                });
            }

            ContextResult <Service.CRM_Venue[]> result = new ContextResult <Service.CRM_Venue[]>()
            {
                ReturnObject = venueList.ToArray()
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #4
0
        public ContextResult <List <string> > ActiveFriendEmails(string authKey)
        {
            bool valid = IsAuthValid(authKey);

            List <string> ActiveFriends = new List <string>();

            if (valid)
            {
                var now = UKTime.Now;

                using (ServiceDataContext db = new ServiceDataContext())
                {
                    foreach (Service.CRM_AnnualPass pass in db.CRM_AnnualPasses.Where(r => r.StartDate <= now && r.ExpiryDate >= now))
                    {
                        Service.CRM_Person person = db.CRM_Persons.FirstOrDefault(f => f.Reference == pass.PrimaryContactReference);

                        if (person != null && person.PrimaryEmail != "")
                        {
                            ActiveFriends.Add(person.PrimaryEmail.ToLower().Trim());
                        }
                    }
                }
            }

            ContextResult <List <string> > result = new ContextResult <List <string> >()
            {
                ReturnObject = ActiveFriends
            };

            result.IsSuccess = valid;

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #5
0
        public void ProcessContextReturnsExpected(string templateString, string arg, ContextResult expected)
        {
            var instanceUnderTest = new HelpOptionParser <object>(Template.Parse(templateString));
            var context           = new ParseContext(new[] { arg });
            var result            = instanceUnderTest.ProcessContext(new object(), context);

            result.ShouldBe(expected);
        }
예제 #6
0
        public override void CustomSave(ContextResult context)
        {
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();

            var list = (from b in context.Results
                       select oSerializer.Serialize((Book)b.CustomBag)).ToArray<string>();

            Persist(Input.Url.Replace(skoobUrl,string.Empty).Replace(":","-").Replace("/"," ").Trim().Replace(" ","-"), string.Join(",", list));
        }
예제 #7
0
        public void MapReturnsProcessContextValue(ContextResult result)
        {
            var parserMock = CreateParserMock(ParserType.Command, false, context => context.TryTakeStringValue(out _),
                                              result);

            Parser <MyOptions>
            .Map(_myOptions, new[] { parserMock.Object }, new ParseContext(new[] { "test" }), ParserType.Command)
            .ShouldBe(result);
        }
예제 #8
0
 public void InitContent()
 {
     tcc.DataContext = tc;
     Assert.IsTrue(tcc.DomId == tc.DomId);
     Assert.IsTrue(tcc.DataContext.Caption == tc.Caption);
     tcc.Caption = "change 1";
     tcc.UpdateDataContext();
     Assert.IsTrue(tcc.Caption == tcc.DataContext.Caption);
     tc.OnCommand.Invoke(this, ContextResult.Cancel());
     Assert.IsTrue(tcc.DataContext.ObjectName == "test");
 }
예제 #9
0
        protected virtual void Closed(ContextAction result, object data)
        {
            DataContext.IsVisabled = false;
            DataContext.OnCommand?.Invoke(this, ContextResult.Cancel());
            OnResult.InvokeAsync(result?.ContextResult(data));

            //DataContext.Child = new TContext<TNull>();
            LoadDataContext();
            base.Close();
            OnCloseAction?.Invoke();
        }
예제 #10
0
        public override ContextResult ParseHtml(Instruction instruction)
        {
            ContextResult context = new ContextResult();
            CrawlerResult output = null;

            string url = instruction.Url;

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(GetContent(url));

            HtmlNodeCollection books = doc.DocumentNode.SelectNodes("//div[@id='resultadoBusca']//div[@class='box_capa_lista_busca']//a[position()=1]");

            HtmlNodeCollection candidateLinks = doc.DocumentNode.SelectNodes("//div[@id='resultadoBusca']//a[@class='l13' and position()=1]");

            foreach (var link in candidateLinks)
            {
                AddCandidateLink(context, string.Format("{0}{1}", "http://www.skoob.com.br", link.Attributes["href"].Value));
            }

            if (books != null)
            {
                foreach (HtmlNode book in books)
                {
                    HtmlDocument internalDoc = new HtmlDocument();
                    internalDoc.LoadHtml(GetContent(string.Format("{0}{1}", skoobUrl, book.Attributes["href"].Value)));

                    HtmlNode title = internalDoc.DocumentNode.SelectSingleNode("//div[@id='barra_titulo']//h1");
                    string bookTitle = string.Empty;
                    if (title != null)
                        bookTitle = title.InnerText;

                    HtmlNode author = internalDoc.DocumentNode.SelectSingleNode("//div[@id='barra_autor']//a");
                    string bookAuthor = string.Empty;
                    if (author != null)
                        bookAuthor = author.InnerText;

                    HtmlNode editions = internalDoc.DocumentNode.SelectSingleNode("//div[@id='menubusca']//a[@title='Edições']");
                    string bookEditionsUrl = string.Empty;
                    if (editions != null)
                    {
                        bookEditionsUrl = string.Format("{0}{1}", skoobUrl, editions.Attributes["href"].Value);
                        List<Book> bookEditions = GetBooksFromEdition(bookTitle, bookAuthor, bookEditionsUrl);
                        foreach (Book bookEdition in bookEditions)
                        {
                            context.Results.Add(new CrawlerResult() { CustomBag = bookEdition });
                        }
                    }
                }
            }

            return context;
        }
예제 #11
0
 public void Init()
 {
     tcc = new TestComponent();
     tc  = new TestContent {
         Caption = "OK"
     };
     tc.OnCommand += (o, e) =>
     {
         e             = ContextResult.No("no");
         tc.ObjectName = "test";
         tc.LoadDataContext();
     };
 }
예제 #12
0
        public ContextResult <CRM_Title[]> GetTitles(string authkey)
        {
            MainDataContext             db     = new MainDataContext();
            var                         items  = db.CRM_Titles.ToArray().OrderBy(c => c.DisplayName).ToArray();
            ContextResult <CRM_Title[]> result = new ContextResult <CRM_Title[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #13
0
        public ContextResult <Service.Country[]> GetCountries(string authkey)
        {
            ServiceDataContext db = new ServiceDataContext();

            ContextResult <Service.Country[]> result = new ContextResult <Service.Country[]>()
            {
                ReturnObject = db.Countries.ToArray()
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #14
0
        public ContextResult <Service.CRM_RelationCode[]> GetRelationshipCodes(string authkey)
        {
            ServiceDataContext db = new ServiceDataContext();
            var items             = db.CRM_RelationCodes.ToArray().OrderBy(c => c.Name).ToArray();
            ContextResult <Service.CRM_RelationCode[]> result = new ContextResult <Service.CRM_RelationCode[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #15
0
        public ContextResult <Service.CRM_AnnualPassType[]> GetMemberships(string authkey)
        {
            ServiceDataContext db = new ServiceDataContext();
            var items             = db.CRM_AnnualPassTypes.Where(r => r.IsWebsite && !r.IsArchived).ToArray().OrderBy(c => c.Name).ToArray();
            ContextResult <Service.CRM_AnnualPassType[]> result = new ContextResult <Service.CRM_AnnualPassType[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #16
0
        public ContextResult <Service.CRM_Person> GetPersonRecord(string authkey, int WebsiteAccountID)
        {
            ServiceDataContext db = new ServiceDataContext();

            Service.CRM_Person personAccount = db.CRM_Persons.FirstOrDefault(s => s.WebsiteAccountID == WebsiteAccountID);

            ContextResult <Service.CRM_Person> result = new ContextResult <Service.CRM_Person>()
            {
                ReturnObject = personAccount
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #17
0
        private static Mock <IArgumentParser <MyOptions> > CreateParserMock(ParserType parserType, bool multiValued,
                                                                            Action <ParseContext> parseAction,
                                                                            ContextResult result)
        {
            var mock = new Mock <IArgumentParser <MyOptions> >();

            mock.SetupGet(m => m.MultiValued).Returns(multiValued);
            mock.SetupGet(m => m.ParserType).Returns(parserType);
            mock.Setup(m => m.ProcessContext(It.IsAny <MyOptions>(), It.IsAny <ParseContext>()))
            .Returns <MyOptions, ParseContext>((_, ctx) =>
            {
                parseAction(ctx);
                return(result);
            })
            .Verifiable();

            return(mock);
        }
        // Invokes the parser on the context arguments
        private static ContextResult InvokeParser(TOptions options,
                                                  ParseContext parseContext,
                                                  ContextResult result,
                                                  IArgumentParser <TOptions> parser)
        {
            while (parseContext.Ready)
            {
                var state = parseContext.Count;
                result |= parser.ProcessContext(options, parseContext);

                if (state != parseContext.Count && !parser.MultiValued)
                {
                    break;
                }
            }

            return(result);
        }
예제 #19
0
        public ContextResult <Service.CRM_FormFieldItem[]> GetInterests(string authkey)
        {
            ServiceDataContext db = new ServiceDataContext();

            Service.CRM_FormFieldItem[] items = db.CRM_FormFieldItems.Where(f => f.CRM_FormFieldID == 24).OrderBy(o => o.OrderNo).ToArray();


            ContextResult <Service.CRM_FormFieldItem[]> result = new ContextResult <Service.CRM_FormFieldItem[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);


            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #20
0
        public SpecificationStatus Execute(Type spectorun)
        {
            var classname = spectorun.Name.Replace("Spec","");
            var contexts = GetContexts(spectorun);
            var specobj = (BaseSpec)Activator.CreateInstance(spectorun)  ;
            var specresults = new List<ContextResult>();

            foreach (var method in contexts)
            {

                var resultsbefore = specobj.ContextResults.ToArray();
                method.Invoke(specobj, null);
                var newresults = specobj.ContextResults.Except(resultsbefore);
                var specresult = new ContextResult(classname,   method.Name.Replace("_", " "), newresults);

                specresults.Add(specresult);
            }

            return new SpecificationStatus(classname, specresults);
        }
예제 #21
0
        /// <summary>
        /// [DEPENDS ON: CdnInfoContext, Mumble Link API]
        /// If <see cref="ContextAvailability.Available"/>, returns if the client is the
        /// <see cref="ClientType.Standard"/> client or the <see cref="ClientType.Chinese"/> client.
        /// </summary>
        public ContextAvailability TryGetClientType(out ContextResult <ClientType> contextResult)
        {
            int currentBuildId;

            if (GameService.Gw2Mumble.IsAvailable)
            {
                currentBuildId = GameService.Gw2Mumble.Info.BuildId;
            }
            else
            {
                contextResult = new ContextResult <ClientType>(ClientType.Unknown, "The Guild Wars 2 Mumble Link API was not available.");
                return(ContextAvailability.NotReady);
            }

            var standardClient = IsStandardClientType(currentBuildId, out var standardCdnStatus);

            if (standardClient.IsMatch)
            {
                contextResult = new ContextResult <ClientType>(ClientType.Standard);
                return(ContextAvailability.Available);
            }

            var chineseClient = IsChineseClientType(currentBuildId, out var chineseCdnStatus);

            if (chineseClient.IsMatch)
            {
                contextResult = new ContextResult <ClientType>(ClientType.Chinese);
                return(ContextAvailability.Available);
            }

            if (standardClient.CdnAvailability == ContextAvailability.Available && chineseClient.CdnAvailability == ContextAvailability.Available)
            {
                contextResult = new ContextResult <ClientType>(ClientType.Unknown, $"The build ID reported by the Mumble Link API ({currentBuildId}) could not be matched against a CDN provided build ID.");
                return(ContextAvailability.Failed);
            }

            contextResult = new ContextResult <ClientType>(ClientType.Unknown, $"The CDN context is either not ready or failed to load.");
            return(ContextAvailability.Unavailable);
        }
예제 #22
0
        public ContextResult <InterestAnswer[]> GetCurrentInterests(string authkey, int WebsiteAccountID)
        {
            ServiceDataContext db = new ServiceDataContext();

            Service.CRM_Person personAccount = db.CRM_Persons.FirstOrDefault(s => s.WebsiteAccountID == WebsiteAccountID);

            InterestAnswer[] items = (from a in db.CRM_FormFieldAnswers
                                      where a.CRM_FormFieldID == 24 && a.TargetReference == personAccount.Reference
                                      select new InterestAnswer {
                FormFieldID = a.CRM_FormFieldID, OptIn = a.Answer == "Yes"
            }).ToArray();

            ContextResult <InterestAnswer[]> result = new ContextResult <InterestAnswer[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
예제 #23
0
        public void TestAddContext()
        {
            var publicId = GetUniquePublicId();

            var uploadParams = new ImageUploadParams()
            {
                File      = new FileDescription(m_testImagePath),
                PublicId  = publicId,
                Overwrite = true,
                Type      = STORAGE_TYPE_UPLOAD,
                Tags      = m_apiTag
            };

            m_cloudinary.Upload(uploadParams);

            List <string> pIds = new List <string> {
                publicId
            };

            ContextResult contextResult = m_cloudinary.Context(new ContextParams()
            {
                Command      = ContextCommand.Add,
                PublicIds    = pIds,
                Type         = STORAGE_TYPE_UPLOAD,
                Context      = "TestContext",
                ResourceType = ResourceType.Image
            });

            Assert.True(contextResult.PublicIds.Length > 0);

            m_cloudinary.GetResource(new GetResourceParams(pIds[0])
            {
                PublicId     = pIds[0],
                Type         = STORAGE_TYPE_UPLOAD,
                ResourceType = ResourceType.Image
            });
        }
예제 #24
0
 public override void Cancel()
 {
     CloseItem(ContextResult.Cancel());
 }
        protected ContextResult CreateTopReferable(
            ImportCellMatchContextBase context,
            bool actInHierarchy = false)
        {
            // access
            if (context?.Parent == null || _sm == null)
            {
                return(null);
            }

            // what element to create? makes this sense?
            var fen = FilteredElementName.Parse(context.ParentElemName);

            if (fen == null)
            {
                return(null);
            }
            if (fen.Name != AdminShell.Key.Submodel &&
                fen.NameEnum != AdminShell.SubmodelElementWrapper.AdequateElementEnum.Unknown &&
                fen.NameEnum != AdminShell.SubmodelElementWrapper.AdequateElementEnum.SubmodelElementCollection)
            {
                return(null);
            }

            // special case: directly into the (existing) Submodel
            ContextResult res = null;

            if (fen.Name == AdminShell.Key.Submodel)
            {
                // prepare the result (already)
                res = new ContextResult()
                {
                    Elem     = _sm,
                    Wrappers = _sm.submodelElements
                };

                // kind of manually take over data
                // this changes the actual data of the Submodel the plugin is associated with!
                AasConvertHelper.TakeOverSmeToSm(context.Parent, _sm);

                // ok
                return(res);
            }

            // ok, if not, then ordinary case: create a SME and add it (somewhere) to the SM
            // this ALREADY should take over the most of the data
            // Note: value data is not required, as fixed to SMC!
            var sme = AdminShell.SubmodelElementWrapper.CreateAdequateType(fen.NameEnum, context.Parent);

            if (!(sme is AdminShell.SubmodelElementCollection smesmc))
            {
                return(null);
            }

            smesmc.value = new AdminShell.SubmodelElementWrapperCollection();

            res = new ContextResult()
            {
                Elem     = sme,
                Wrappers = smesmc.value
            };

            // try to act within the hierarchy
            // does only search SME but no SM, however, this is not a flaw, as adding to SM is the default
            if (actInHierarchy && context.ParentParentName.HasContent() && context.Parent.idShort.HasContent())
            {
                foreach (var rootsmc in _sm.submodelElements.FindDeep <AdminShell.SubmodelElementCollection>((testsmc) =>
                {
                    // first condition is, that the parents match!
                    if (!testsmc.idShort.HasContent() || testsmc.parent == null)
                    {
                        return(false);
                    }

                    // try testing of allowed parent names
                    if (!(testsmc.parent is AdminShell.Referable testsmcpar))
                    {
                        return(false);
                    }
                    var test1 = context.ParentParentName.ToLower().Contains(testsmcpar.idShort.ToLower().Trim());
                    var test2 = false;
                    if (_idShortToParentName.ContainsKey(testsmcpar.idShort))
                    {
                        foreach (var pn in _idShortToParentName[testsmcpar.idShort])
                        {
                            test2 = test2 || context.ParentParentName.ToLower().Contains(pn.ToLower().Trim());
                        }
                    }

                    if (!(test1 || test2))
                    {
                        return(false);
                    }

                    // next is, that some part of of given idShort match the idShort of children
                    // of investigated SMC
                    var parts = context.Parent.idShort.Split(new[] { ',', ';', '|' },
                                                             StringSplitOptions.RemoveEmptyEntries);
                    foreach (var part in parts)
                    {
                        if (part?.Trim().ToLower() == testsmc.idShort.Trim().ToLower())
                        {
                            return(true);
                        }
                    }

                    // or, maybe more meaningful, if the semantic ids are the same?
                    if (context.Parent.semanticId?.IsEmpty == false &&
                        testsmc.semanticId?.IsEmpty == false &&
                        testsmc.semanticId.Matches(context.Parent.semanticId, AdminShell.Key.MatchMode.Relaxed))
                    {
                        return(true);
                    }

                    // not found
                    return(false);
                }))
                {
                    // rootsmc contains a valid SMC to the above criteria
                    // NOTHING needs to be added; found SMC needs to be given back
                    res.Elem     = rootsmc;
                    res.Wrappers = rootsmc.value;

                    // this seems to be a valid ParentName, which is now "renamed" by the idShort
                    // of the SMC
                    _idShortToParentName.Add(rootsmc.idShort, context.Parent.idShort);

                    // need to adopt the rootsmc further by parent information??
                    ;

                    // ok
                    return(res);
                }
            }

            // simply add new SMC directly to SM
            _sm.Add(sme);
            return(res);
        }
예제 #26
0
        //Check XmlDocument for documentation on HtmlAgilityPack
        //XPath cheat sheet http://xpath.alephzarro.com/content/cheatsheet.html
        public override ContextResult ParseHtml(Instruction instruction)
        {
            ContextResult context = new ContextResult();
            CrawlerResult output = null;

            string url = instruction.Url;

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(GetContent(url));

            HtmlNodeCollection posts = doc.DocumentNode.SelectNodes("//div[@id='content']//div[contains(@class,'post') and contains(@class,'status-publish')]");

            HtmlNodeCollection candidateLinks = doc.DocumentNode.SelectNodes("//div[@id='postnav']//a[contains(.,'Próxima')]");

            if (candidateLinks != null)
            {
                foreach (var link in candidateLinks)
                {
                    AddCandidateLink(context, link.Attributes["href"].Value);
                }
            }

            foreach (HtmlNode post in posts)
            {
                output = new CrawlerResult();
                HtmlNode title = post.SelectSingleNode(".//h3[@class='storytitle']");
                HtmlNode content = post.SelectSingleNode(".//div[@class='storycontent']");
                HtmlNodeCollection tags = post.SelectNodes(".//div[@class='meta']//a");

                if (title != null && content != null)
                {
                    HtmlNode postUrl = title.SelectSingleNode(".//a");
                    //if (title.ChildNodes.Count > 0 && title.ChildNodes[0].Attributes["href"] != null)
                        //output.Url = title.ChildNodes[0].Attributes["href"].Value;
                    if (postUrl != null)
                        output.Url = postUrl.Attributes["href"].Value;

                    output.Title = System.Web.HttpUtility.HtmlDecode(title.InnerText);
                    output.Content = content.InnerHtml;
                    //var aux = Sanitize.Strip(output.Content);

                    HtmlNode date = post.SelectSingleNode(".//h3[@class='storytitle']//span[@class='date']");

                    if (date != null)
                    {
                        output.Data = (new LeitoraCompulsivaData() { Date = date.InnerText }).ToJson();
                    }

                    if (tags != null)
                    {
                        List<string> postTags = new List<string>();
                        foreach (var tag in tags)
                        {
                            postTags.Add(tag.InnerText);
                        }
                        output.Tags = string.Join(", ", postTags.ToArray());
                    }

                    context.Results.Add(output);
                }
            }

            return context;
        }
        protected ContextResult CreateBodyCD(
            ImportCellMatchContextBase context,
            AdminShell.AdministrationShellEnv env)
        {
            // access
            if (context?.Sme == null || context?.CD == null || env == null || _options == null)
            {
                return(null);
            }

            // first test, if the CD already exists
            var test = env.FindConceptDescription(context.Sme.semanticId);

            if (test != null)
            {
                return new ContextResult()
                       {
                           Elem = test
                       }
            }
            ;

            // a semanticId is required to link the Sme and the CD together
            if (context.Sme.semanticId == null || context.Sme.semanticId.Count < 1)
            {
                // generate a new one for SME + CD
                // this modifies the SME!
                var id = new AdminShell.Identification(
                    AdminShell.Identification.IRI,
                    AdminShellUtil.GenerateIdAccordingTemplate(_options.TemplateIdConceptDescription));

                context.Sme.semanticId = new AdminShell.SemanticId(
                    new AdminShell.Key(AdminShell.Key.ConceptDescription, true, id.idType, id.id));
            }

            // create, add
            var cd = new AdminShell.ConceptDescription(context?.CD);

            env.ConceptDescriptions.Add(cd);
            var res = new ContextResult()
            {
                Elem = cd
            };

            // link CD to SME
            var sid = context.Sme.semanticId.GetAsExactlyOneKey();

            if (sid == null)
            {
                // should not happen, see above
                return(null);
            }
            cd.identification = new AdminShell.Identification(sid.idType, sid.value);

            // some further attributes
            if (!cd.idShort.HasContent())
            {
                cd.idShort = context.Sme.idShort;
            }

            // ok
            return(res);
        }
        protected ContextResult CreateBodySme(
            ImportCellMatchContextBase context,
            ContextResult refTop)
        {
            // access
            if (context?.Sme == null || refTop?.Wrappers == null)
            {
                return(null);
            }

            // make sure, there is an 'ordniary' SME to create
            var fen = FilteredElementName.Parse(context.SmeElemName);

            if (fen == null)
            {
                return(null);
            }
            if (fen.NameEnum == AdminShellV20.SubmodelElementWrapper.AdequateElementEnum.Unknown)
            {
                return(null);
            }

            // create, add
            var sme = AdminShell.SubmodelElementWrapper.CreateAdequateType(fen.NameEnum, context.Sme);

            refTop.Wrappers.Add(sme);
            sme.parent = refTop.Elem; // unfortunately required, ass Wrapper.Add() cannot set parent
            var res = new ContextResult()
            {
                Elem = sme
            };

            // allow a selection a values
            if (sme is AdminShell.Property prop)
            {
                prop.value = context.SmeValue;

                // demux
                prop.valueType = fen.ValueType;
                if (!fen.ValueType.HasContent() && context.SmeValueType.HasContent())
                {
                    prop.valueType = context.SmeValueType;
                }
            }

            if (sme is AdminShell.MultiLanguageProperty mlp)
            {
                mlp.value = new AdminShell.LangStringSet(AdminShell.LangStr.LANG_DEFAULT, context.SmeValue);
            }

            if (sme is AdminShell.File file)
            {
                file.value = context.SmeValue;
            }

            if (sme is AdminShell.SubmodelElementCollection smc)
            {
                smc.value    = new AdminShell.SubmodelElementWrapperCollection();
                res.Wrappers = smc.value;
            }

            // ok
            return(res);
        }