Пример #1
0
        protected override AbstractSource DoCreateNewSource(string name, string url, List <MetaDataObject> templateAndValues)
        {
            string value;
            int    tmp;

            MetaDataObject source = MetaDataObject.FindIn(templateAndValues, SmackProvider.META_SOURCE);

            value = source.GetValueAsString();

            if (String.IsNullOrEmpty(value))
            {
                throw new Exception("No source selected");
            }

            AbstractSource s = new SmackSource(value);

            MetaDataObject pages = MetaDataObject.FindIn(templateAndValues, SmackProvider.META_PAGES);

            value = pages.GetValueAsString();

            if (String.IsNullOrEmpty(value))
            {
                tmp = DefaultPages;
            }
            else
            {
                int.TryParse(value, out tmp);
            }

            pages.SetValue(tmp);

            s.SetMetaData(templateAndValues);

            return(s);
        }
Пример #2
0
        //TODO: Need to set display name elsewhere and metaData type
        private Dictionary <string, IMetaDataObject> DeserializeMeta(string meta)
        {
            string[] data = meta.Split(MetaDelim);

            Dictionary <string, IMetaDataObject> kvs = new Dictionary <string, IMetaDataObject>();

            foreach (string kv in data)
            {
                int    split = kv.IndexOf('=');
                string key   = kv.Substring(0, split);
                string value = kv.Substring(split + 1);

                MetaDataObject mdo = new MetaDataObject(key, null, MetaDataObjectType.NA);
                mdo.SetValue(value);

                kvs.Add(key, mdo);
            }

            return(kvs);
        }
Пример #3
0
        public static SourceAdapter CreateSourceAdapter(V1.AbstractSource src, V1.AbstractProvider provider)
        {
            string strDisabled = src.GetMetaDataValue(AbstractSource.DISABLED);
            bool   disabled    = strDisabled == null ? false : Convert.ToBoolean(strDisabled);

            GenericSource gs = new GenericSource(src.SourceName, src.ProviderID, disabled);

            //Update Meta
            Dictionary <string, MetaDataObject> newMeta = new Dictionary <string, MetaDataObject>();

            List <string> providerMeta = provider.GetMetaFields();

            {
                foreach (string name in providerMeta)
                {
                    var mdo = new MetaDataObject(name, name);
                    if (src.GetMetaData().ContainsKey(name))
                    {
                        mdo.SetValue(src.GetMetaDataValue(name));
                    }

                    newMeta.Add(mdo.ID, mdo);
                }
            }

            gs.SetMetaData(newMeta);

            if (src.ID.HasValue)
            {
                gs.SetID(src.ID.Value);
            }

            var sa = new SourceAdapter(gs);


            return(sa);
        }