Пример #1
0
        public RootFolder(PhysicalOverviewShellFolderServer server, ShellItemIdList idList)
            : base(idList)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            Hello = new HelloWorldItem(this);

            // get a path like C:\Users\<user>\AppData\Local\ShellBoost.Samples.PhysicalOverview\Root
            RootPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GetType().Namespace), "Root");

            // ensure it exists
            var di = new DirectoryInfo(RootPath);

            if (!di.Exists)
            {
                di.Create();
            }

            RootPhysical = new PhysicalFolder(this, di);
            Server       = server;

            // we want to know when something changes in the real folder so we can update ours
            // note we don't use .NET's FileSystemWatcher but a Shell-oriented ShellBoost-provider tool instead base on native Shell's APIs.
            ChangeNotifier         = new ChangeNotifier(ShellUtilities.GetIdList(RootPath), true);
            ChangeNotifier.Notify += OnChangeNotifierNotify;
        }
 public SyncController(Helpers.DateHelper dateHelper, DataStorage dataStorage, ChangeNotifier changeNotifier, Errors errors)
 {
     _dateHelper     = dateHelper;
     _dataStorage    = dataStorage;
     _changeNotifier = changeNotifier;
     _errors         = errors;
 }
Пример #3
0
        private ChangeNotifier CreateNotifier()
        {
            var connectionName = _manager.NotificationConnection ?? _manager.ConnectionString;
            var notifier       = new ChangeNotifier(connectionName);

            return(notifier);
        }
Пример #4
0
        public ReactiveTable()
        {
            var type = typeof(T);

            foreach (var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Where(p => p.GetCustomAttribute <CalculatedColumnAttribute>() == null))
            {
                AddColumn(ReactiveColumn.Create($"{type.Name}.{propertyInfo.Name}", propertyInfo.PropertyType));
            }

            var token = Subscribe(update =>
            {
                if (update.Action == TableUpdateAction.Add)
                {
                    var item = new T();
                    item.SetTable(this);
                    item.SetRowIndex(update.RowIndex);
                    ChangeNotifier.RegisterPropertyNotifiedConsumer(item, update.RowIndex);
                    Flyweights.Add(item);
                }
                else if (update.Action == TableUpdateAction.Delete)
                {
                    // TODO: Look at efficiency of this
                    var item = Flyweights[update.RowIndex];
                    ChangeNotifier.UnregisterPropertyNotifiedConsumer(item, update.RowIndex);
                    Flyweights.RemoveAt(update.RowIndex);
                }
            });
        }
Пример #5
0
		public StudyFilterColumnHeaderCell()
			: base()
		{
			_dataGridViewChangeNotifier = new ChangeNotifier<DataGridView>(
				delegate(DataGridView oldValue, DataGridView newValue)
					{
						if (oldValue != null)
							this.UnsubscribeDataGridViewEvents(oldValue);
					},
				delegate(DataGridView oldValue, DataGridView newValue)
					{
						if (newValue != null)
							this.SubscribeDataGridViewEvents(newValue);
					});
		}
Пример #6
0
 private void HandleEvent(string siteName, string wikiUrl)
 {
     // notify any interested parties
     ChangeNotifier.NotifyPageUpdated(siteName, wikiUrl);
 }
Пример #7
0
        public override void Export(string filename)
        {
            using (LdapConnection connect = new LdapConnection(new LdapDirectoryIdentifier(Server, Port == 0 ? 389 : Port), Credential))
            {
                var    filter        = "(&(objectClass=*))";
                var    searchRequest = new SearchRequest(null, filter, SearchScope.Base);
                var    response      = connect.SendRequest(searchRequest) as SearchResponse;
                string root          = (string)response.Entries[0].Attributes["defaultNamingContext"][0];
                connect.Bind();

                using (StreamWriter sw = File.CreateText(filename))
                {
                    var header = new List <string>();
                    header.Add("Date");
                    header.Add("DistinguishedName");
                    header.Add("Attribute");
                    header.Add("Value");

                    sw.WriteLine(string.Join("\t", header.ToArray()));


                    EventHandler <ObjectChangedEventArgs> callback =
                        (object sender, ObjectChangedEventArgs e) =>
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        DisplayAdvancement(e.Result.DistinguishedName);
                        Console.ResetColor();
                        foreach (string attributeName in e.Result.Attributes.AttributeNames)
                        {
                            foreach (byte[] item in e.Result.Attributes[attributeName].GetValues(typeof(byte[])))
                            {
                                string i;
                                // there is no easy way to know the synthax of the object
                                // see https://social.technet.microsoft.com/wiki/contents/articles/52570.active-directory-syntaxes-of-attributes.aspx

                                // so we try each well known type one by one
                                try
                                {
                                    i = new SecurityIdentifier(item, 0).Value;
                                }
                                catch
                                {
                                    try
                                    {
                                        i = new Guid(item).ToString();
                                    }
                                    catch
                                    {
                                        try
                                        {
                                            i = Encoding.UTF8.GetString(item);
                                            for (int j = 0; j < i.Length; j++)
                                            {
                                                var ch  = i[j];
                                                var ich = (int)ch;
                                                if (ich > 127 || ich < 31)     // not ascii or extended ascii
                                                {
                                                    i = BitConverter.ToString(item);
                                                    break;
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            i = BitConverter.ToString(item);
                                        }
                                    }
                                }

                                //Console.WriteLine("{0}: {1}", attributeName, i);
                                var data = new List <string>();
                                data.Add(DateTime.Now.ToString("u"));
                                data.Add(e.Result.DistinguishedName);
                                data.Add(attributeName);
                                data.Add(i);
                                sw.WriteLine(string.Join("\t", data.ToArray()));
                                sw.Flush();
                            }
                        }
                    };


                    using (ChangeNotifier notifier = new ChangeNotifier(connect))
                    {
                        //register some objects for notifications (limit 5)
                        notifier.Register(root, SearchScope.Subtree);

                        notifier.ObjectChanged += callback;

                        DisplayAdvancement("Waiting for changes...");
                        DisplayAdvancement("Press ENTER to stop monitoring the changes");
                        Console.ReadLine();
                    }
                }

                DisplayAdvancement("Done");
            }
        }
Пример #8
0
 /*
 ============================================================================
 Change notifier functions
 ============================================================================
 */
 public static void RegisterChangeNotifier(ChangeNotifier c)
 {
     GameHandler.Instance().changeNotifiers.Add(c);
 }