Example #1
0
        public List <ItemChangeMetadata> GetMetadataForChanges(ChangeBatch sourceChanges)
        {
            // Increment the tick count
            GetNextTickCount();

            // Increase local knowledge tick count.
            SyncKnowledge.SetLocalTickCount(TickCount);

            // Create a collection to hold the changes we'll put into our batch
            List <ItemChangeMetadata> changes = new List <ItemChangeMetadata>();

            foreach (ItemChange ic in sourceChanges)
            {
                ItemMetadata       item;
                ItemChangeMetadata change;
                // Iterate through each item to get the corresponding version in the local store
                if (MetadataStore.TryGetItem(ic.ItemId, out item))
                {
                    // Found the corresponding item in the local metadata
                    // Get the local creation version and change (update) version from the metadata
                    change = new ItemChangeMetadata(item.ItemId, item.IsTombstone ? ChangeKind.Deleted : ChangeKind.Update, item.CreationVersion, item.ChangeVersion);
                }
                else
                {
                    // Remote item has no local counterpart
                    // This item is unknown to us
                    change = new ItemChangeMetadata(ic.ItemId, ChangeKind.UnknownItem, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);
                }

                // Add our change to the change list
                changes.Add(change);
            }

            return(changes);
        }
Example #2
0
        void RegisterCustomMetadata()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(Parallel), new DesignerAttribute(typeof(CustomParallelDesigner)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #3
0
        private static void OnConfigChange(object sender, FileSystemEventArgs e)
        {
            if (counter == 0)
            {
                counter++;
                return;
            }

            counter = 0;
            try
            {
                logWriter?.Dispose();
                logStream?.Dispose();
                Listener.Config = Config.ParseConfig(out logStream, out logWriter);
            }
            catch (Exception ex)
            {
                Log(new ApiLogMessage($"Failed to de-serialize config, using current config instead. Exception: {ex.Message}{Environment.NewLine}{ex.StackTrace}", ApiLogLevel.Warning));
            }
            Listener.Stop();
            Listener.Start();
            try
            {
                MetadataStore.LoadMetadata(Log);
            }
            catch (Exception ex)
            {
                Log(new ApiLogMessage($"Failed to load metadata. Exception: {ex.Message}{Environment.NewLine}{ex.StackTrace}", ApiLogLevel.Critical));
            }
        }
Example #4
0
        // TODO : remove parameter itemType if generic constraints allow internal and parameterized constructors.
        // Parameter itemType is used as a workaround to instanciate a VolumeItem object,
        // because the internal VolumeItem constructor with the database parameter can't be used in generic code.
        // see http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=9a8e58ee-1371-4e99-8385-c3e2a4157fd6
        // see http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=80517ec1-2d08-43cc-bc90-9927877061a9

        /// <summary>
        /// Returns a specific VolumeItem object, but preassigns properties of the VolumeItem baseclass only.
        /// Filling properties of the specific, derived object, is job of the specific VolumeScanner implementation.
        /// </summary>
        /// <typeparam name="TVolumeItem">Type of the specific volume item.</typeparam>
        /// <returns>
        /// A new specific VolumeItem derived from base class VolumeItem
        /// with all base class properties preassigned.
        /// </returns>
        protected TVolumeItem GetNewVolumeItem <TVolumeItem>(long parentID,
                                                             string name,
                                                             string mimeType,
                                                             MetadataStore metaData,
                                                             VolumeItemType itemType)
            where TVolumeItem : VolumeItem
        {
            // TODO: check here if TMediaItem applies to TMedia?

            /* TVolumeItem item = new TVolumeItem(database); */
            TVolumeItem item = (TVolumeItem)VolumeItem.CreateInstance(itemType, database);

            // initialize fields of the VolumeItem base class.
            // don't initialize via properties. initializing via properties is error-prone
            // as the compiler won't error if a new field is added to the base class
            // and forgotten to be initialized here.
            item.SetVolumeItemFields(volume.VolumeID,
                                     itemID,
                                     parentID,
                                     name,
                                     mimeType,
                                     metaData,
                                     null,
                                     null);

            itemID++;

            return(item);
        }
        // [TestMethod]

        public async Task SimpleCall()
        {
            var metadataStore = new MetadataStore();
            var orderBuilder  = new EntityTypeBuilder <Order>(metadataStore);
            var dp            = orderBuilder.DataProperty(o => o.ShipAddress).MaxLength(40);

            orderBuilder.DataProperty(o => o.OrderID).IsPartOfKey();
            orderBuilder.NavigationProperty(o => o.Customer).HasInverse(c => c.Orders).HasForeignKey(o => o.CustomerID);
            orderBuilder.NavigationProperty(o => o.Employee).HasInverse(emp => emp.Orders).HasForeignKey(o => o.EmployeeID);
            orderBuilder.NavigationProperty(o => o.OrderDetails).HasInverse(od => od.Order);

            var odBuilder = new EntityTypeBuilder <OrderDetail>(metadataStore);

            odBuilder.DataProperty(od => od.OrderID).IsPartOfKey();
            odBuilder.DataProperty(od => od.ProductID).IsPartOfKey();
            odBuilder.NavigationProperty(od => od.Order).HasInverse(o => o.OrderDetails).HasForeignKey(od => od.OrderID);
            odBuilder.NavigationProperty(od => od.Product).HasForeignKey(o => o.ProductID);

            var empBuilder = new EntityTypeBuilder <Employee>(metadataStore);

            empBuilder.DataProperty(emp => emp.EmployeeID).IsPartOfKey();
            empBuilder.NavigationProperty(emp => emp.Orders).HasInverse(o => o.Employee);
            empBuilder.NavigationProperty(emp => emp.Manager).HasInverse(emp => emp.DirectReports).HasForeignKey(emp => emp.ReportsToEmployeeID);

            var prodBuilder = new EntityTypeBuilder <Product>(metadataStore);

            prodBuilder.DataProperty(p => p.ProductID).IsPartOfKey();
            prodBuilder.NavigationProperty(prod => prod.Category).HasForeignKey(prod => prod.CategoryID);
        }
        static MessageBoxActivity()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(MessageBoxActivity), "Buttons", new EditorAttribute(typeof(ButtonsClickTypeEditor), typeof(PropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #7
0
        public void Register()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            Type stateMachineType = typeof(StateMachine);

            builder.AddCustomAttributes(stateMachineType, new DesignerAttribute(typeof(StateMachineDesigner)));
            builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateContainerEditor.ChildStatesPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateMachineDesigner.VariablesPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateMachineDesigner.InitialStatePropertyName), BrowsableAttribute.No);

            Type stateType = typeof(State);

            builder.AddCustomAttributes(stateType, new DesignerAttribute(typeof(StateDesigner)));
            builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.EntryPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.ExitPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateType, stateType.GetProperty(StateContainerEditor.ChildStatesPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.TransitionsPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.IsFinalPropertyName), BrowsableAttribute.No);

            Type transitionType = typeof(Transition);

            builder.AddCustomAttributes(transitionType, new DesignerAttribute(typeof(TransitionDesigner)));
            builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.TriggerPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.ActionPropertyName), BrowsableAttribute.No);
            builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.ToPropertyName), BrowsableAttribute.No);

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
        static DoubleClickActivity()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(DoubleClickActivity), "KeyModifiers", new EditorAttribute(typeof(KeyModifiersEditor), typeof(PropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #9
0
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");


            builder.AddCustomAttributes(typeof(MLScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(MLScope), new DesignerAttribute(typeof(MLScopeDesigner)));
            builder.AddCustomAttributes(typeof(MLScope), new HelpKeywordAttribute("https://go.uipath.com"));

            builder.AddCustomAttributes(typeof(LoadFromTextFile), categoryAttribute);
            builder.AddCustomAttributes(typeof(LoadFromTextFile), new DesignerAttribute(typeof(LoadFromTextFileDesigner)));
            builder.AddCustomAttributes(typeof(LoadFromTextFile), new HelpKeywordAttribute("https://go.uipath.com"));

            builder.AddCustomAttributes(typeof(SaveToTextFile), categoryAttribute);
            builder.AddCustomAttributes(typeof(SaveToTextFile), new DesignerAttribute(typeof(SaveToTextFileDesigner)));
            builder.AddCustomAttributes(typeof(SaveToTextFile), new HelpKeywordAttribute("https://go.uipath.com"));

            builder.AddCustomAttributes(typeof(SelectColumns), categoryAttribute);
            builder.AddCustomAttributes(typeof(SelectColumns), new DesignerAttribute(typeof(SelectColumnsDesigner)));
            builder.AddCustomAttributes(typeof(SelectColumns), new HelpKeywordAttribute("https://go.uipath.com"));

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #10
0
        // <summary>
        // Initializes the metadata provided by this class.  Multiple class
        // are ignored.
        // </summary>
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            // Introduce any Cider-specific customizations
            AttributeTableBuilder builder = new AttributeTableBuilder();

            // Make Name and FlowDirection properties browsable.  The reason why
            // these attributes are here instead of in the BaseOverridesAttributeTable
            // is because the BaseAttributeTable explicitly hides these properties
            // and adding conflicting attributes to the same table (via BaseOverridesAttributeTable
            // which derives from BaseAttributeTable) currently results in unspeciefied
            // behavior.  Hence we use this table to deal with these attributes.
            //
            MakeBasic(builder, typeof(FrameworkElement), FrameworkElement.FlowDirectionProperty);
            MakeBasic(builder, typeof(Control), Control.NameProperty);

            // Note: Add any new attributes here or into System.Activities.Presentation.Developer /
            // System.Activities.Presentation.Internal.Metadata.BaseOverridesAttributeTable

            MetadataStore.AddAttributeTable(builder.CreateTable());

            _initialized = true;
        }
Example #11
0
        public void Register()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(HashFile), new DesignerAttribute(typeof(HashFileActivityDesigner)));
            builder.AddCustomAttributes(typeof(HashText), new DesignerAttribute(typeof(HashTextActivityDesigner)));
            builder.AddCustomAttributes(typeof(KeyedHashFile), new DesignerAttribute(typeof(KeyedHashFileActivityDesigner)));
            builder.AddCustomAttributes(typeof(KeyedHashText), new DesignerAttribute(typeof(KeyedHashTextActivityDesigner)));
            builder.AddCustomAttributes(typeof(EncryptFile), new DesignerAttribute(typeof(EncryptFileActivityDesigner)));
            builder.AddCustomAttributes(typeof(EncryptText), new DesignerAttribute(typeof(EncryptTextActivityDesigner)));
            builder.AddCustomAttributes(typeof(DecryptFile), new DesignerAttribute(typeof(DecryptFileActivityDesigner)));
            builder.AddCustomAttributes(typeof(DecryptText), new DesignerAttribute(typeof(DecryptTextActivityDesigner)));

            // Categories
            CategoryAttribute cryptographyCategoryAttribute =
                new CategoryAttribute($"{Resources.CategorySystem}.{Resources.CategoryCryptography}");

            builder.AddCustomAttributes(typeof(HashFile), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(HashText), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(KeyedHashFile), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(KeyedHashText), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(EncryptFile), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(EncryptText), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(DecryptFile), cryptographyCategoryAttribute);
            builder.AddCustomAttributes(typeof(DecryptText), cryptographyCategoryAttribute);

            //DisplayName
            AddToAll(builder, typeof(HashFile).Assembly, nameof(Activity.DisplayName), new DisplayNameAttribute(Resources.DisplayName));

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #12
0
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            var categoryAttribute = new CategoryAttribute("App Scripting");
            var autoHotKeyType    = typeof(RunAutoHotKeyScript);

            builder.AddCustomAttributes(autoHotKeyType, categoryAttribute);
            builder.AddCustomAttributes(autoHotKeyType, "Parameters", new EditorAttribute(typeof(CollectionArgumentEditor), typeof(DialogPropertyValueEditor)));
            builder.AddCustomAttributes(autoHotKeyType, "Result", new CategoryAttribute("Output"));
            builder.AddCustomAttributes(autoHotKeyType, new DesignerAttribute(typeof(ScriptActivityDesigner)));

            var psType = typeof(RunPowerShellScript <>);

            builder.AddCustomAttributes(psType, categoryAttribute);
            builder.AddCustomAttributes(psType, "Parameters", new EditorAttribute(typeof(DictionaryArgumentEditor), typeof(DialogPropertyValueEditor)));
            builder.AddCustomAttributes(psType, new DesignerAttribute(typeof(ScriptActivityDesigner)));
            builder.AddCustomAttributes(psType, new DefaultTypeArgumentAttribute(typeof(object)));

            Type attrType            = Type.GetType("System.Activities.Presentation.FeatureAttribute, System.Activities.Presentation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
            Type argType             = Type.GetType("System.Activities.Presentation.UpdatableGenericArgumentsFeature, System.Activities.Presentation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
            var  genericTypeArgument = Activator.CreateInstance(attrType, new object[] { argType }) as Attribute;

            builder.AddCustomAttributes(psType, genericTypeArgument);

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
        public async Task StoresMetadataCorrectly()
        {
            (var authenticator, _, var usernameParser, var credFactory, var sysIdProvider) = SetupAcceptEverything();
            var storeProvider = new StoreProvider(new InMemoryDbStoreProvider());
            IEntityStore <string, string> store = storeProvider.GetEntityStore <string, string>("productInfo");
            var    metadataStore = new MetadataStore(store, "productInfo");
            string modelIdString = "dtmi:test:modelId;1";

            using (var sut = new AuthAgentProtocolHead(authenticator, metadataStore, usernameParser, credFactory, sysIdProvider, config))
            {
                await sut.StartAsync();

                dynamic content = new ExpandoObject();
                content.version  = "2020-04-20";
                content.username = $"testhub/device/api-version=2018-06-30&model-id={modelIdString}";
                // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Synthetic password used in tests")]
                content.password = "******";

                dynamic response = await PostAsync(content, this.url);

                Assert.Equal(200, (int)response.result);
                var modelId = (await metadataStore.GetMetadata("device")).ModelId;
                Assert.True(modelId.HasValue);
                Assert.Equal(modelIdString, modelId.GetOrElse("impossibleValue"));
            }
        }
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");

            builder.AddCustomAttributes(typeof(SFTPScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(SFTPScope), new DesignerAttribute(typeof(SFTPScopeDesigner)));
            builder.AddCustomAttributes(typeof(SFTPScope), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(Download), categoryAttribute);
            builder.AddCustomAttributes(typeof(Download), new DesignerAttribute(typeof(DownloadDesigner)));
            builder.AddCustomAttributes(typeof(Download), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(Upload), categoryAttribute);
            builder.AddCustomAttributes(typeof(Upload), new DesignerAttribute(typeof(UploadDesigner)));
            builder.AddCustomAttributes(typeof(Upload), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(Delete), categoryAttribute);
            builder.AddCustomAttributes(typeof(Delete), new DesignerAttribute(typeof(DeleteDesigner)));
            builder.AddCustomAttributes(typeof(Delete), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetFiles), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetFiles), new DesignerAttribute(typeof(GetFilesDesigner)));
            builder.AddCustomAttributes(typeof(GetFiles), new HelpKeywordAttribute(""));


            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #15
0
        public MainWindow()
        {
            InitializeComponent();
            new BluEnergyXDesignerStart().ShowDialog();

            errorService = new ValidationErrorService(this.messageListBox);

            originalTitle = this.Title;
            //register designers for the standard activities
            DesignerMetadata dm = new DesignerMetadata();

            dm.Register();
            //toolbox
            toolboxControl    = CreateToolbox();
            toolboxArea.Child = toolboxControl;
            CreateContextMenu();

            InitializeDesigner();
            StartNewWorkflow();

            //override designer for the standard While activity
            AttributeTableBuilder atb = new AttributeTableBuilder();

            atb.AddCustomAttributes(typeof(While), new DesignerAttribute(typeof(ActivityLibrary.Design.MyWhileDesigner)));
            MetadataStore.AddAttributeTable(atb.CreateTable());
        }
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");

            builder.AddCustomAttributes(typeof(ZendeskScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(ZendeskScope), new DesignerAttribute(typeof(ZendeskScopeDesigner)));
            builder.AddCustomAttributes(typeof(ZendeskScope), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetTicket), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetTicket), new DesignerAttribute(typeof(GetTicketDesigner)));
            builder.AddCustomAttributes(typeof(GetTicket), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(UpdateTicket), categoryAttribute);
            builder.AddCustomAttributes(typeof(UpdateTicket), new DesignerAttribute(typeof(UpdateTicketDesigner)));
            builder.AddCustomAttributes(typeof(UpdateTicket), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetUser), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetUser), new DesignerAttribute(typeof(GetUserDesigner)));
            builder.AddCustomAttributes(typeof(GetUser), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetUserFields), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetUserFields), new DesignerAttribute(typeof(GetUserFieldsDesigner)));
            builder.AddCustomAttributes(typeof(GetUserFields), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetTicketFieldOption), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetTicketFieldOption), new DesignerAttribute(typeof(GetTicketFieldOptionDesigner)));
            builder.AddCustomAttributes(typeof(GetTicketFieldOption), new HelpKeywordAttribute(""));


            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
        public void Register()
        {
            CategoryAttribute category = new CategoryAttribute(Resources.DropboxActivitiesCategory);

            AttributeTableBuilder builder = new AttributeTableBuilder();
            ShowPropertyInOutlineViewAttribute hideFromOutlineAttribute = new ShowPropertyInOutlineViewAttribute()
            {
                CurrentPropertyVisible = false, DuplicatedChildNodesVisible = false
            };

            builder.AddCustomAttributes(typeof(WithDropboxSession), nameof(WithDropboxSession.Body), hideFromOutlineAttribute);

            builder.AddCustomAttributes(typeof(Copy), category);
            builder.AddCustomAttributes(typeof(CreateFile), category);
            builder.AddCustomAttributes(typeof(CreateFolder), category);
            builder.AddCustomAttributes(typeof(Delete), category);
            builder.AddCustomAttributes(typeof(DownloadFile), category);
            builder.AddCustomAttributes(typeof(DownloadFolderAsZip), category);
            builder.AddCustomAttributes(typeof(GetFolderContent), category);
            builder.AddCustomAttributes(typeof(Move), category);
            builder.AddCustomAttributes(typeof(UploadFile), category);
            builder.AddCustomAttributes(typeof(WithDropboxSession), category);

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
        public async Task MetadataMissingClrType()
        {
            try {
                //MetadataStore.Instance.AllowedMetadataMismatchTypes = MetadataMismatchType.AllAllowable;
                var serviceName = "http://sampleservice.breezejs.com/api/todos/";

                var em     = new EntityManager(serviceName);
                var mmargs = new List <MetadataMismatchEventArgs>();
                MetadataStore.Instance.MetadataMismatch += (s, e) => {
                    mmargs.Add(e);
                    Assert.IsTrue(e.StructuralTypeName.ToUpper().Contains("TODO"), "entityTypeName should be TODO");
                    Assert.IsTrue(e.PropertyName == null, "propertyName should be null");
                    Assert.IsTrue(e.Allow == false, "allow should be false");
                    e.Allow = (e.MetadataMismatchType == MetadataMismatchType.MissingCLREntityType);
                };
                var x = await em.FetchMetadata();

                Assert.IsTrue(mmargs.Count == 1, "should be only one mismatch, but found: " + mmargs.Count);
                var errors = MetadataStore.Instance.GetMessages(MessageType.Error);
                Assert.IsTrue(errors.Count() == 0, "should be 0 errors: " + errors.ToAggregateString("..."));
                Assert.IsTrue(MetadataStore.Instance.GetMessages().Count() == 1, "should be 1 message");
            }
            finally {
                MetadataStore.__Reset();
            }
        }
        public async Task MetadataWithEmbeddedQuotes()
        {
            try {
                // this is a legacy service that has quoted metadata.
                var serviceName = "http://sampleservice.breezejs.com/api/todos/";
                var ds          = new DataService(serviceName);

                var metadata = await ds.GetAsync("Metadata");

                var metadata2 = System.Text.RegularExpressions.Regex.Unescape(metadata).Trim('"');
                var jo        = (JObject)JsonConvert.DeserializeObject(metadata2);
                var em        = new EntityManager(ds);
                try {
                    var x = await em.FetchMetadata();

                    Assert.Fail("should not get here - CLR types for this metadata are not available");
                }
                catch (Exception e) {
                    Assert.IsTrue(e.Message.Contains("CLR Entity"));
                }
            }
            finally {
                MetadataStore.__Reset();
            }
        }
        /// <summary>
        /// Return the attribute table that is applied to design time.
        /// </summary>
        public void Register()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            LayoutMetadata.AddAttributes(builder);
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #21
0
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(RemoveConfigurationActivity), new DesignerAttribute(typeof(RemoveConfigurationActivityDesigner)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #22
0
        //构造函数自定义属性框
        public InsertJS()
        {
            var builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(InsertJS), nameof(InsertJS.Parameters), new EditorAttribute(typeof(ArgumentCollectionEditor), typeof(DialogPropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #23
0
        static InvokeComMethodActivity()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(InvokeComMethodActivity), "Arguments", new EditorAttribute(typeof(DictionaryArgumentEditor), typeof(DialogPropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #24
0
        public SendMail()
        {
            var builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(SendMail), "Files", new EditorAttribute(typeof(ArgumentCollectionEditor), typeof(DialogPropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
        static PathExistsActivity()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(PathExistsActivity), "PathType", new EditorAttribute(typeof(PathTypeEditor), typeof(PathTypeEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #26
0
        internal override void ImportThreadMain(string sourceDbPath,
                                                VolumeDatabase targetDb,
                                                string dbDataPath,
                                                BufferedVolumeItemWriter writer)
        {
            this.counters = new long[3];
            //idCounter = 2; // id 1 is the root item
            //totalMedia = 0;
            this.path           = new Stack <string>();
            this.mimePathPrefix = GetNonExistingPath() + "/";
            this.targetDb       = targetDb;
            this.writer         = writer;

            using (GZipStream s = new GZipStream(File.OpenRead(sourceDbPath), CompressionMode.Decompress)) {
                XmlReaderSettings settings = new XmlReaderSettings()
                {
                    DtdProcessing   = DtdProcessing.Ignore,
                    ValidationType  = ValidationType.None,
                    CheckCharacters = false
                };

                XmlReader reader = XmlTextReader.Create(s, settings);

                XmlDocument xml = new XmlDocument();
                xml.Load(reader);

                string        dummy1 = null;
                MetadataStore dummy2 = MetadataStore.Empty;

                RecursiveDump(xml.DocumentElement, 0L, 0L, ref dummy1, ref dummy1, ref dummy2);
            }
        }
Example #27
0
        public ExecNoQuery()
        {
            var builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(typeof(ExecNoQuery), nameof(ExecNoQuery.Parameters), new EditorAttribute(typeof(DictionaryArgumentEditor), typeof(DialogPropertyValueEditor)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #28
0
        //这个方法是为了加载左边控件库的图标
        private static void LoadToolboxIconsForBuiltInActivities()
        {
            try
            {
                var sourceAssembly = Assembly.LoadFrom(@"Lib\Microsoft.VisualStudio.Activities.dll");

                var builder = new AttributeTableBuilder();

                if (sourceAssembly != null)
                {
                    var stream =
                        sourceAssembly.GetManifestResourceStream(
                            "Microsoft.VisualStudio.Activities.Resources.resources");
                    if (stream != null)
                    {
                        var resourceReader = new ResourceReader(stream);

                        foreach (var type in
                                 typeof(System.Activities.Activity).Assembly.GetTypes().Where(
                                     t => t.Namespace == "System.Activities.Statements"))
                        {
                            CreateToolboxBitmapAttributeForActivity(builder, resourceReader, type);
                        }
                    }
                }

                MetadataStore.AddAttributeTable(builder.CreateTable());
            }
            catch (FileNotFoundException)
            {
                // Ignore - will use default icons
            }
        }
        public static void RegisterAll()
        {
            var builder = new AttributeTableBuilder();

            ImageDetectorActivityDesign.RegisterMetadata(builder);
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #30
0
        public void Register()
        {
            #region Setup

            var builder = new AttributeTableBuilder();
            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");

            #endregion Setup


            builder.AddCustomAttributes(typeof(BitbucketAPIScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(BitbucketAPIScope), new DesignerAttribute(typeof(BitbucketAPIScopeDesigner)));
            builder.AddCustomAttributes(typeof(BitbucketAPIScope), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetRepositories), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetRepositories), new DesignerAttribute(typeof(GetRepositoriesDesigner)));
            builder.AddCustomAttributes(typeof(GetRepositories), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(ManageRepository), categoryAttribute);
            builder.AddCustomAttributes(typeof(ManageRepository), new DesignerAttribute(typeof(ManageRepositoryDesigner)));
            builder.AddCustomAttributes(typeof(ManageRepository), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(CommitFile), categoryAttribute);
            builder.AddCustomAttributes(typeof(CommitFile), new DesignerAttribute(typeof(CommitFileDesigner)));
            builder.AddCustomAttributes(typeof(CommitFile), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetWorkspaces), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetWorkspaces), new DesignerAttribute(typeof(GetWorkspacesDesigner)));
            builder.AddCustomAttributes(typeof(GetWorkspaces), new HelpKeywordAttribute(""));


            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Example #31
0
 public static async Task<EntityManager> NewEm(DataService dataService, MetadataStore metadataStore = null) {
   metadataStore = metadataStore ?? DefaultMetadataStore;
   if (dataService.HasServerMetadata && metadataStore.GetDataService(dataService.ServiceName) == null) {
     var em = new EntityManager(dataService.ServiceName, metadataStore);
     await em.FetchMetadata();
     return em;
   } else {
     return new EntityManager(dataService, metadataStore);
   }
 }
Example #32
0
 public async Task<EntityManager> SetUpAsync() {
   var serviceName = "http://localhost:7150/breeze/NorthwindIBModel/";
   
   if (__metadataStore == null) {
     _em1 = new EntityManager(serviceName);
     await _em1.FetchMetadata();
     __metadataStore = _em1.MetadataStore;
   } else {
     _em1 = new EntityManager(serviceName);
   }
   return _em1;
   
 }
Example #33
0
    public static void Initialize(MetadataStore metadataStore) {
      

      var makeBuilder = new EntityTypeBuilder<Make>(metadataStore);
      makeBuilder.DataProperty(make => make.Id).IsPartOfKey();
      makeBuilder.DataProperty(make => make.Name).MaxLength(40);
      // makeBuilder.NavigationProperty(make => make.Models).HasInverse(model => model.Make);
      
      var modelBuilder = new EntityTypeBuilder<Model>(metadataStore);
      modelBuilder.DataProperty(model => model.Id).IsPartOfKey();
      modelBuilder.NavigationProperty(model => model.Make)
        .HasForeignKey(model => model.MakeId)
        .HasInverse(make => make.Models);
       
      
    }
    // [TestMethod]
    // This test can only be run standalone because of the __Reset call
    public async Task ExpMetadata() {
      var em1 = await TestFns.NewEm(_serviceName);

      var metadata = em1.MetadataStore.ExportMetadata();
      File.WriteAllText("c:/temp/metadata.txt", metadata);

      var ms = Configuration.Instance;

      
      Assert.IsTrue(ms != Configuration.Instance);
      var ms2 = new MetadataStore();
      ms2.ImportMetadata(metadata);
      var metadata2 = ms2.ExportMetadata();

      File.WriteAllText("c:/temp/metadata2.txt", metadata2);
      Assert.IsTrue(metadata == metadata2, "metadata should match between export and import");
    }
    public async Task MetadataMissingClrProperty() {
      
      var ms = new MetadataStore();
      ms.NamingConvention = new MorphedClassNamingConvention();
      var em = new EntityManager(_serviceName, ms);

      em.MetadataStore.AllowedMetadataMismatchTypes = MetadataMismatchTypes.AllAllowable;
        
      var mmargs = new List<MetadataMismatchEventArgs>();
      em.MetadataStore.MetadataMismatch += (s, e) => {
        mmargs.Add(e);
      };
      var x = await em.FetchMetadata();
      Assert.IsTrue(mmargs.Count > 4, "should be more than 4 mismatches, but found: " + mmargs.Count);
      var errors = em.MetadataStore.GetMessages(MessageType.Error);
      Assert.IsTrue(errors.Count() == 0, "should be 0 errors: " + errors.ToAggregateString("..."));
      Assert.IsTrue(em.MetadataStore.GetMessages().Count() >= 4, "should be more than 4 message");
    }
    public async Task BadURL() {

      var serviceName = "http://localhost:7150/breeze/xxxFoo";
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("metadata resource"));
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("metadata resource"));
      }
    }
    public async Task NoClrTypes() {
      
      var serviceName = TestFns.serviceName;
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      }
      catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }
    }
    public async Task NoClrTypes() {
      
      var serviceName = "http://localhost:7150/breeze/NorthwindIBModel";
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      }
      catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }
    }
Example #39
0
File: Broker.cs Project: GNOME/nemo
        protected Broker(bool reindex)
        {
            types = new Dictionary<string,string>();

            System.Console.WriteLine("reindex: {0}, first run {1}", reindex, Singleton<Configuration>.Instance.data.first_run);

            if (reindex || Singleton<Configuration>.Instance.data.first_run)
            {
                reindex_metadata_store();
                Singleton<Configuration>.Instance.data.first_run = false;
                Singleton<Configuration>.Instance.save_configuration();
            }

            cur_search_id = 0;

            // metadata store
            if (meta == null) {
                meta = new MetadataStore(Singleton<Configuration>.Instance.data.watch_dir);
                meta.start(System.IO.Path.Combine(Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), ".nemo/"));
            }
        }
Example #40
0
    public static async Task<EntityManager> NewEm(string serviceName, MetadataStore metadataStore = null) {
      metadataStore = metadataStore ?? DefaultMetadataStore;
#if NHIBERNATE
      metadataStore.AllowedMetadataMismatchTypes = MetadataMismatchType.MissingCLREntityType;
      var nc = metadataStore.NamingConvention.WithClientServerNamespaceMapping("Foo", "Models.NorthwindIB.NH");
      metadataStore.NamingConvention = nc;
#else
      metadataStore.MetadataMismatch += (s, e) => {
        if (e.StructuralTypeInfo.ShortName == "Geospatial") {
          e.Allow = true;
        }
      };

#endif
      var em = new EntityManager(serviceName, metadataStore);
      if (metadataStore.GetDataService(serviceName) == null) {
        await em.FetchMetadata();
      } 

      return em;
    }
Example #41
0
        // FIXME: re-hook this in the UI
        //        static string GetExportLabel (ExportItem export)
        //        {
        //            switch (export.ExportType) {
        //            case ExportStore.FlickrExportType:
        //                string[] split_token = export.ExportToken.Split (':');
        //                return String.Format ("Flickr ({0})", split_token[1]);
        //            case ExportStore.OldFolderExportType:	//Obsolete, remove after db rev4
        //                return Catalog.GetString ("Folder");
        //            case ExportStore.FolderExportType:
        //                return Catalog.GetString ("Folder");
        //            case ExportStore.PicasaExportType:
        //                return Catalog.GetString ("Picasaweb");
        //            case ExportStore.SmugMugExportType:
        //                return Catalog.GetString ("SmugMug");
        //            case ExportStore.Gallery2ExportType:
        //                return Catalog.GetString ("Gallery2");
        //            default:
        //                return null;
        //            }
        //        }
        //        
        //        static string GetExportUrl (ExportItem export)
        //        {
        //            switch (export.ExportType) {
        //            case ExportStore.FlickrExportType:
        //                string[] split_token = export.ExportToken.Split (':');
        //                return String.Format ("http://www.{0}/photos/{1}/{2}/", split_token[2],
        //                                                      split_token[0], split_token[3]);
        //            case ExportStore.FolderExportType:
        //                Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (export.ExportToken);
        //                return (uri.HasParent) ? uri.Parent.ToString () : export.ExportToken;
        //            case ExportStore.Gallery2ExportType:
        //                string[] split_item = export.ExportToken.Split (':');
        //                return String.Format ("{0}:{1}?g2_itemId={2}",split_item[0], split_item[1], split_item[2]);
        //            case ExportStore.OldFolderExportType:	//This is obsolete and meant to be removed once db reach rev4
        //            case ExportStore.PicasaExportType:
        //            case ExportStore.SmugMugExportType:
        //                return export.ExportToken;
        //            default:
        //                return null;
        //            }
        //        }
        private bool Update()
        {
            TreeIter iter;
            ListStore model;
            string name;
            bool empty = true;
            bool missing = false;
            System.Exception error = null;

            up_to_date = true;

            int i = 0;
            int index_of_expander = 0;

            // Write Exif-Data
            if (exif_info != null) {
                foreach (Exif.ExifContent content in exif_info.GetContents ()) {
                    Exif.ExifEntry [] entries = content.GetEntries ();

                    i++;

                    if (entries.Length < 1)
                        continue;

                    empty = false;

                    name = Exif.ExifUtil.GetIfdNameExtended ((Exif.Ifd)i - 1);

                    if (index_of_expander >= exif_vbox.Children.Length)
                        model = AddExpander (name, index_of_expander);
                    else {
                        Expander expander = (Expander)exif_vbox.Children[index_of_expander];
                        if (expander.Label == name)
                            model = (ListStore)((TreeView)expander.Child).Model;
                        else {
                            model = AddExpander (name, index_of_expander);
                        }
                    }

                    model.GetIterFirst(out iter);

                    foreach (Exif.ExifEntry entry in entries) {
                        string s;

                        if (entry.Title != null)
                            s = String.Format ("{0}\n\t<small>{1}</small>", entry.Title, entry.Value);
                        else
                            s = String.Format ("Unknown Tag ID={0}\n\t<small>{1}</small>", entry.Tag.ToString (), entry.Value);

                        if (model.IterIsValid(iter)) {
                            model.SetValue (iter, 0, s);
                            model.IterNext(ref iter);
                        } else
                            model.AppendValues (s);
                    }

                    // remove rows, that are not used
                    while (model.IterIsValid(iter)) {
                        model.Remove (ref iter);
                    }

                    index_of_expander++;
                }
            }

            // Write Extended Metadata
            if (photo != null) {
                MetadataStore store = new MetadataStore ();
                try {
                    using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) {
                        if (img is SemWeb.StatementSource) {
                            StatementSource source = (StatementSource)img;
                            source.Select (store);
                        }
                    }
                } catch (System.IO.FileNotFoundException) {
                    missing = true;
                } catch (System.Exception e){
                    // Sometimes we don't get the right exception, check for the file
                    if (!System.IO.File.Exists (photo.DefaultVersionUri.LocalPath)) {
                        missing = true;
                    } else {
                        // if the file is there but we still got an exception display it.
                        error = e;
                    }
                }

                model = extended_metadata;
                model.GetIterFirst(out iter);

                if (store.StatementCount > 0) {
                    empty = false;

                    foreach (Statement stmt in store) {
                        // Skip anonymous subjects because they are
                        // probably part of a collection
                        if (stmt.Subject.Uri == null && store.SelectSubjects (null, stmt.Subject).Length > 0)
                            continue;

                        string title;
                        string value;
                        string s;

                        Description.GetDescription (store, stmt, out title, out value);

                        if (value == null)
                        {
                            MemoryStore substore = store.Select (new Statement ((Entity)stmt.Object, null, null, null)).Load();
                            StringBuilder collection = new StringBuilder ();
                            collection.Append (title);
                            WriteCollection (substore, collection);
                            if (model.IterIsValid(iter))
                            {
                                model.SetValue (iter, 0, collection.ToString ());
                                model.IterNext(ref iter);
                            } else
                                model.AppendValues (collection.ToString ());
                        } else {
                            s = String.Format ("{0}\n\t<small>{1}</small>", title, value);
                            if (model.IterIsValid(iter))
                            {
                                model.SetValue (iter, 0, s);
                                model.IterNext(ref iter);
                            } else
                                model.AppendValues (s);
                        }
                    }

                } else {
                    // clear Extended Metadata
                    String s = String.Format ("<small>{0}</small>", Catalog.GetString ("No Extended Metadata Available"));
                    if (model.IterIsValid(iter))
                    {
                        model.SetValue (iter, 0, s);
                        model.IterNext(ref iter);
                    } else
                        model.AppendValues (s);
                }

                // remove rows, that are not used
                while (model.IterIsValid(iter)) {
                    model.Remove (ref iter);
                }
            }

            if (empty) {
                string msg;
                if (photo == null) {
                     msg = Catalog.GetString ("No active photo");
                } else if (missing) {
                    msg = String.Format (Catalog.GetString ("The photo \"{0}\" does not exist"),
                                                            photo.DefaultVersionUri);
                } else {
                     msg = Catalog.GetString ("No metadata available");

                    if (error != null) {
                        msg = String.Format ("<i>{0}</i>", error);
                    }
                }

                exif_message.Markup = "<span weight=\"bold\">" + msg + "</span>";

                if (display == State.exif) {
                    // Child is a Viewport, (AddWithViewport in ctor)
                    ((Viewport)Child).Remove (main_vbox);
                    ((Viewport)Child).Add (exif_message);
                    display = State.message;
                    exif_message.Show ();
                }
            } else {
                // remove Expanders, that are not used
                while (index_of_expander < exif_vbox.Children.Length)
                    exif_vbox.Remove (exif_vbox.Children[index_of_expander]);

                if (display == State.message) {
                    // Child is a Viewport, (AddWithViewport in ctor)
                    ((Viewport)Child).Remove (exif_message);
                    ((Viewport)Child).Add (main_vbox);
                    display = State.exif;
                    main_vbox.ShowAll ();
                }
            }

            return false;
        }
Example #42
0
File: Broker.cs Project: GNOME/nemo
        public void reindex_metadata_store()
        {
            System.Console.WriteLine("Reindexing filesystem!");

            if (meta == null) {
                meta = new MetadataStore(Singleton<Configuration>.Instance.data.watch_dir);
                meta.start(System.IO.Path.Combine(Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), ".nemo/"));
            }

            System.Console.WriteLine(Singleton<Configuration>.Instance.data.watch_dir);

            meta.sync_with_filesystem();
        }
Example #43
0
		public XmpFile ()
		{
			store = new MetadataStore ();
		}
 private Tuple<EntityKey, EntityKey> ToEntityKeys(KeyMapping keyMapping, MetadataStore metadataStore) {
   var serverTypeInfo = TypeNameInfo.FromClrTypeName(keyMapping.EntityTypeName);
   var clientEntityTypeName = serverTypeInfo.ToClient(metadataStore).StructuralTypeName;
   var et = metadataStore.GetEntityType(clientEntityTypeName);
   var oldKey = new EntityKey(et, keyMapping.TempValue);
   var newKey = new EntityKey(et, keyMapping.RealValue);
   return Tuple.Create(oldKey, newKey);
 }
Example #45
0
 public TypeNameInfo ToServer(MetadataStore metadataStore) {
   return metadataStore.NamingConvention.ClientTypeNameToServer(this);
 }
Example #46
0
 // within this using block make the DetachedMetadataStore == ms
 public static UsingBlock ShareWithDetached(MetadataStore ms) {
   return UsingBlock.Create(MetadataStore.Detached, ms, (x) => MetadataStore.Detached = x);
 }
Example #47
0
        public void ProcessStore(MetadataStore store, Photo photo)
        {
            Hashtable descriptions = new Hashtable ();
            uint rating = System.UInt32.MaxValue;
            uint urgency = System.UInt32.MaxValue;

            foreach (Statement stmt in store) {
                //StatementList list = null;

                switch (stmt.Predicate.Uri) {

                case Caption:
                case Headline:
                    if (!descriptions.Contains (stmt.Predicate.Uri)) {
                        string caption = GetTextField (stmt.Object as SemWeb.Literal);
                        if (caption != null)
                            caption = caption.Trim ();

                        if ((caption != null) && (caption.Length > 0))
                            descriptions.Add (stmt.Predicate.Uri, caption);
                    }
                    break;
                case Title:
                case Description:
                case UserComment:
                    if (!(stmt.Object is Entity))
                        break;

                    foreach (Statement tag in store.Select (new Statement (stmt.Object as Entity, null, null))) {
                        if ( (tag.Predicate != RdfType) && (!descriptions.Contains (stmt.Predicate.Uri)) ) {
                            string title = null;
                            try {
                                title = (GetTextField ((SemWeb.Literal) tag.Object)).Trim ();
                            } catch {
                            }
                            if ( (title != null) && (title.Length > 0) )
                                descriptions.Add (stmt.Predicate.Uri, title);
                        }
                    }
                    break;

                case Urgency: // Used if Rating was not found
                case Rating:
                    SemWeb.Literal l = stmt.Object as SemWeb.Literal;
                    if (l != null && l.Value != null && l.Value.Length > 0) {
                        uint tmp_ui;
                        try {
                            tmp_ui = System.Convert.ToUInt32 (l.Value);
                        } catch {
                            // Set rating to 0, and continue
                            Log.Debug ("Found illegal rating >{0}< in predicate {1}. Rating cleared",
                                         l.Value, stmt.Predicate.Uri);
                            tmp_ui = 0;
                        }
                        if (tmp_ui > 5) // Max rating allowed in F-Spot
                            tmp_ui = 5;
                        if (stmt.Predicate.Uri == Rating)
                            rating = tmp_ui;
                        else
                            urgency = tmp_ui == 0 ? 0 : tmp_ui - 1; // Urgency valid values 1 - 8
                    }
                    break;

                case State:
                case City:
                case Country:
                case Location:
                case Source:
                    AddTagToPhoto (photo, stmt.Object as SemWeb.Literal, taginfo_table [stmt.Predicate] as TagInfo);
                    break;

                case Subject:
                case SupplementalCategories:
                case People:
                    if (!(stmt.Object is Entity))
                        break;

                    foreach (Statement tag in store.Select (new Statement (stmt.Object as Entity, null, null))) {

                        if (tag.Predicate != RdfType)
                            AddTagToPhoto (photo, tag.Object as SemWeb.Literal, null);

                    }
                    break;
                }
            }

            if (descriptions.Contains (UserComment))
                photo.Description = descriptions [UserComment] as String;

            // Use the old urgency, only if rating was not available.
            if (urgency < System.UInt32.MaxValue)
                photo.Rating = urgency;
            if (rating < System.UInt32.MaxValue)
                photo.Rating = rating;

            #if false
            //FIXME: looks like we are doing some questionable repurposing of tags here...

            // We want to construct the following : Description = <Headline> :: <Caption>

            // only check for more title/comment if you still do not have one.
            if ((photo.Description == null) || (photo.Description.Length == 0)) {
                if (descriptions.Contains (Headline))
                    photo.Description = descriptions [Headline] as String;
                // Lets add the Caption to the existing Description (Headline).
                if (descriptions.Contains (Caption))
                    photo.Description += (( (photo.Description == null) ? "" : " :: ") + descriptions [Caption] as String);
            }

            // only check for more title/comment if you still do not have one.
            if ((photo.Description == null) || (photo.Description.Length == 0)) {
                if (descriptions.Contains (Title))
                    photo.Description = descriptions [Title] as String;
                // Lets add the Description  to the existing Description (Title).
                if (descriptions.Contains (Description))
                    photo.Description += (( (photo.Description == null) ? "" : " :: ") + descriptions [Description] as String);
            }
            #endif
        }
Example #48
0
    public static void Initialize(MetadataStore metadataStore) {

      // Configure keys and relationships
      var personBuilder = new EntityTypeBuilder<Person>(metadataStore);
      personBuilder.DataProperty(person => person.Id).IsPartOfKey();

      var sessionBuilder = new EntityTypeBuilder<Session>(metadataStore);
      sessionBuilder.DataProperty(session => session.Id).IsPartOfKey().IsAutoIncrementing();
      sessionBuilder.NavigationProperty(session => session.Room)
        .HasForeignKey(session => session.RoomId);
      sessionBuilder.NavigationProperty(session => session.TimeSlot)
        .HasForeignKey(session => session.TimeSlotId);
      sessionBuilder.NavigationProperty(session => session.Track)
        .HasForeignKey(session => session.TrackId);
      sessionBuilder.NavigationProperty(session => session.Speaker)
        .HasForeignKey(session => session.SpeakerId)
        .HasInverse(speaker => speaker.SpeakerSessions);

      var roomBuilder = new EntityTypeBuilder<Room>(metadataStore);
      roomBuilder.DataProperty(room => room.Id).IsPartOfKey().IsAutoIncrementing();

      var timeSlotBuilder = new EntityTypeBuilder<TimeSlot>(metadataStore);
      timeSlotBuilder.DataProperty(timeSlot => timeSlot.Id).IsPartOfKey().IsAutoIncrementing();

      var trackBuilder = new EntityTypeBuilder<Track>(metadataStore);
      timeSlotBuilder.DataProperty(track => track.Id).IsPartOfKey().IsAutoIncrementing();

      // Configure constraints
      personBuilder.DataProperty(person => person.FirstName).IsRequired().MaxLength(50);
      personBuilder.DataProperty(person => person.LastName).IsRequired().MaxLength(50);


      sessionBuilder.DataProperty(session => session.TrackId).IsRequired();
      sessionBuilder.DataProperty(session => session.RoomId).IsRequired();
      sessionBuilder.DataProperty(session => session.SpeakerId).IsRequired();
      sessionBuilder.DataProperty(session => session.RoomId).IsRequired();

      sessionBuilder.DataProperty(session => session.Title).IsRequired().MaxLength(50);
      sessionBuilder.DataProperty(session => session.Description).MaxLength(4000);



    }
        public void ProcessStore(MetadataStore store, Photo photo)
        {
            Hashtable desc = new Hashtable ();

            foreach (Statement stmt in store) {
                StatementList list = null;

                switch (stmt.Predicate.Uri) {
                case Description:
                case Headline:
                case Caption:
                case Title:
                case UserComment:
                    list = (StatementList) desc [stmt.Predicate];

                    if (list == null)
                        desc [stmt.Predicate] = list = new StatementList ();

                    list.Add (stmt);
                    break;

                case State:
                case City:
                case Country:
                case Location:
                case Source:
                    AddTagToPhoto (photo, stmt.Object as Literal, taginfo_table [stmt.Predicate] as TagInfo);
                    break;

                case Subject:
                case SupplementalCategories:
                case People:
                    if (!(stmt.Object is Entity))
                        break;

                    foreach (Statement tag in store.Select (new Statement (stmt.Object as Entity, null, null))) {

                        if (tag.Predicate != RdfType)
                            AddTagToPhoto (photo, tag.Object as Literal, null);

                    }
                    break;
                }
            }

            #if false
            /*
             * FIXME I need to think through what bengt was doing here before I put it in
             * it looks like we are doing some questionable repurposing of tags here and above
             */

            if (xmd.GetXmpBag_0 ("UserComment") != null)
                photo.Description = xmd.GetXmpBag_0 ("UserComment");

            // We want to construct the following : Description = <Headline> :: <Caption>

            // only check for more title/comment if you still do not have one.
            if ((photo.Description == null) || (photo.Description.Length == 0)) {
                if (xmd.GetXmpTag ("Headline") != null)
                    photo.Description = xmd.GetXmpTag ("Headline");
                // Lets add the Caption to the existing Description (Headline).
                if (xmd.GetXmpTag ("Caption") != null)
                    photo.Description += (( (photo.Description == null) ? "" : " :: ") + xmd.GetXmpTag ("Caption"));
            }

            // only check for more title/comment if you still do not have one.
            if ((photo.Description == null) || (photo.Description.Length == 0)) {
                if (xmd.GetXmpTag ("title") != null)
                    photo.Description = xmd.GetXmpTag ("title");
                // Lets add the Description  to the existing Description (Title).
                if (xmd.GetXmpTag ("description") != null)
                    photo.Description += (( (photo.Description == null) ? "" : " :: ") + xmd.GetXmpTag ("description"));
            }
            #endif
        }