コード例 #1
0
ファイル: Clr.cs プロジェクト: miyconst/StarcounterImporter
        /// <summary>
        /// Checks if the given value is a foreign key relation and returns ExporterRelation instance if so, null otherwise
        /// </summary>
        /// <param name="Value"></param>
        /// <returns></returns>
        public ImporterRelation ParseRelation(object Entity, object Value)
        {
            if (Value == null || !(Value is string)) {
                return null;
            }

            string id = Value as string;
            Regex reg = new Regex(@"^[[]ObjectNo:\d+[]]$");

            if (!reg.IsMatch(id)) {
                return null;
            }

            id = Regex.Replace(id, @"\D+", string.Empty);

            ImporterRelation relation = new ImporterRelation() {
                ForeignID = ulong.Parse(id),
                Entity = Entity
            };

            return relation;
        }
コード例 #2
0
 protected void ApplyRelation(Dictionary<ulong, object> Objects, ImporterRelation Relation)
 {
     object foreign = Objects[Relation.ForeignID];
     Relation.Property.SetValue(Relation.Entity, foreign);
 }