Esempio n. 1
0
 ///<summary>Inserts one RegistrationKey into the database.  Returns the new priKey.</summary>
 internal static long Insert(RegistrationKey registrationKey)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         registrationKey.RegistrationKeyNum=DbHelper.GetNextOracleKey("registrationkey","RegistrationKeyNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(registrationKey,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     registrationKey.RegistrationKeyNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(registrationKey,false);
     }
 }
Esempio n. 2
0
 ///<summary>Inserts one RegistrationKey into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(RegistrationKey registrationKey,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         registrationKey.RegistrationKeyNum=ReplicationServers.GetKey("registrationkey","RegistrationKeyNum");
     }
     string command="INSERT INTO registrationkey (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="RegistrationKeyNum,";
     }
     command+="PatNum,RegKey,Note,DateStarted,DateDisabled,DateEnded,IsForeign,UsesServerVersion,IsFreeVersion,IsOnlyForTesting,VotesAllotted) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(registrationKey.RegistrationKeyNum)+",";
     }
     command+=
              POut.Long  (registrationKey.PatNum)+","
         +"'"+POut.String(registrationKey.RegKey)+"',"
         +"'"+POut.String(registrationKey.Note)+"',"
         +    POut.Date  (registrationKey.DateStarted)+","
         +    POut.Date  (registrationKey.DateDisabled)+","
         +    POut.Date  (registrationKey.DateEnded)+","
         +    POut.Bool  (registrationKey.IsForeign)+","
         +    POut.Bool  (registrationKey.UsesServerVersion)+","
         +    POut.Bool  (registrationKey.IsFreeVersion)+","
         +    POut.Bool  (registrationKey.IsOnlyForTesting)+","
         +    POut.Int   (registrationKey.VotesAllotted)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         registrationKey.RegistrationKeyNum=Db.NonQ(command,true);
     }
     return registrationKey.RegistrationKeyNum;
 }
Esempio n. 3
0
		///<summary>Retrieves all registration keys for a particular customer's family. There can be multiple keys assigned to a single customer, or keys assigned to individual family members, since the customer may have multiple physical locations of business.</summary>
		public RegistrationKey[] GetForPatient(long patNum) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<RegistrationKey[]>(MethodBase.GetCurrentMethod(),patNum);
			}
			string command="SELECT * FROM registrationkey WHERE ";
			Family fam=Patients.GetFamily(patNum);
			for(int i=0;i<fam.ListPats.Length;i++){
				command+="PatNum="+POut.Long(fam.ListPats[i].PatNum)+" ";
				if(i<fam.ListPats.Length-1){
					command+="OR ";
				}
			}
			DataTable table=db.GetTable(command);
			RegistrationKey[] keys=new RegistrationKey[table.Rows.Count];
			for(int i=0;i<keys.Length;i++){
				keys[i]=new RegistrationKey();
				keys[i].RegistrationKeyNum	=PIn.Long(table.Rows[i][0].ToString());
				keys[i].PatNum							=PIn.Long(table.Rows[i][1].ToString());
				keys[i].RegKey							=PIn.String(table.Rows[i][2].ToString());
				keys[i].Note								=PIn.String(table.Rows[i][3].ToString());
				keys[i].DateStarted 				=PIn.Date(table.Rows[i][4].ToString());
				keys[i].DateDisabled				=PIn.Date(table.Rows[i][5].ToString());
				keys[i].DateEnded   				=PIn.Date(table.Rows[i][6].ToString());
				keys[i].IsForeign   				=PIn.Bool(table.Rows[i][7].ToString());
				keys[i].UsesServerVersion		=PIn.Bool(table.Rows[i][8].ToString());
				keys[i].IsFreeVersion		    =PIn.Bool(table.Rows[i][9].ToString());
				keys[i].IsOnlyForTesting		=PIn.Bool(table.Rows[i][10].ToString());
				keys[i].VotesAllotted   		=PIn.Int (table.Rows[i][11].ToString());
			}
			return keys;
		}
Esempio n. 4
0
 public Action<object, object, IParameterResolver> this[RegistrationKey key]
 {
     get
     {
         return Handlers[key];
     }
 }
Esempio n. 5
0
		public RegistrationKey GetByKey(string regKey) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<RegistrationKey>(MethodBase.GetCurrentMethod(),regKey);
			}
			if(!Regex.IsMatch(regKey,@"^[A-Z0-9]{16}$")) {
				throw new ApplicationException("Invalid registration key format.");
			}
			string command="SELECT * FROM  registrationkey WHERE RegKey='"+POut.String(regKey)+"'";
			DataTable table=db.GetTable(command);
			if(table.Rows.Count==0) {
				throw new ApplicationException("Invalid registration key.");
			}
			RegistrationKey key=null;
			for(int i=0;i<table.Rows.Count;i++) {
				key=new RegistrationKey();
				key.RegistrationKeyNum	=PIn.Int(table.Rows[i][0].ToString());
				key.PatNum							=PIn.Int(table.Rows[i][1].ToString());
				key.RegKey							=PIn.String(table.Rows[i][2].ToString());
				key.Note								=PIn.String(table.Rows[i][3].ToString());
				key.DateStarted 				=PIn.Date(table.Rows[i][4].ToString());
				key.DateDisabled				=PIn.Date(table.Rows[i][5].ToString());
				key.DateEnded   				=PIn.Date(table.Rows[i][6].ToString());
				key.IsForeign   				=PIn.Bool(table.Rows[i][7].ToString());
				//key.UsesServerVersion  	=PIn.PBool(table.Rows[i][8].ToString());
				key.IsFreeVersion  			=PIn.Bool(table.Rows[i][9].ToString());
				key.IsOnlyForTesting  	=PIn.Bool(table.Rows[i][10].ToString());
				//key.VotesAllotted     	=PIn.PInt(table.Rows[i][11].ToString());
			}
			//if(key.DateDisabled.Year>1880){
			//	throw new ApplicationException("This key has been disabled.  Please call for assistance.");
			//}
			return key;
		}
Esempio n. 6
0
        public bool IsRegistered <T>(string name)
        {
            Type typeToResolve = typeof(T);

            var keyToResolve = new RegistrationKey(typeToResolve, name);

            return(registrations.ContainsKey(keyToResolve));
        }
Esempio n. 7
0
 public virtual object Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
 {
     if (solvingStrategy == SolvingStrategy.PerDependency)
     {
         return(ResolvePerDependency(container, keyToResolve, resolutionPath));
     }
     return(ResolvePerContext(container, keyToResolve, resolutionPath));
 }
Esempio n. 8
0
        private IocBuilder AddRegistration <TAbstract>(RegistrationTag tag, Func <object> lambda)
        {
            var type = typeof(TAbstract);

            lastItem = new RegistrationItem(tag, lambda);
            lastKey  = new RegistrationKey(type);
            registrations.Add(lastKey, lastItem);
            return(this);
        }
Esempio n. 9
0
        public async Task <IActionResult> OnPostUnregisterAsync()
        {
            ReferencedCalendarItem = await _repository.GetDocument(CalendarItemId);

            UseCaptcha = !User.Identity.IsAuthenticated && null != ReferencedCalendarItem && ReferencedCalendarItem.PublicListing;
            if (UseCaptcha)
            {
                RecaptchaResponse captchaValid = await _recaptcha.Validate(Request);

                if (!captchaValid.success)
                {
                    ModelState.AddModelError("reCaptcha", "Bitte das reCaptcha bestätigen.");
                }
            }
            if (!ModelState.IsValid)
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
            Member        memberToUnregister;
            List <Member> members;

            if (null == ReferencedCalendarItem)
            {
                return(new NotFoundResult());
            }
            members            = (ReferencedCalendarItem.Members != null) ? new List <Member>(ReferencedCalendarItem.Members) : new List <Member>();
            memberToUnregister = members.Find(m => m.EMail == NewMember.EMail && m.Name == NewMember.Name);
            if (null == memberToUnregister)
            {
                ModelState.AddModelError("EMail", "E-Mail und Name stimmen mit keiner Anmeldung überein.");
                return(Page());
            }
            if (ReferencedCalendarItem.RegistrationKeyRequired)
            {
                RegistrationKey checkKey = ReferencedCalendarItem.RegistrationKeys.FirstOrDefault(r => r.Key == NewMember.RegistrationKey);
                if (null == checkKey)
                {
                    ModelState.AddModelError("RegistrationKey", "Der angegebene Registrierungsschlüssel ist nicht zulässig.");
                    return(Page());
                }
            }
            if (ModelState.IsValid)
            {
                members.RemoveAll(c => c.UniqueId == memberToUnregister.UniqueId);
                ReferencedCalendarItem.Members = members.OrderBy(m => m.RegistrationDate).ToArray();
                await _repository.UpsertDocument(ReferencedCalendarItem);

                ViewData["Message"] = "Abgemeldet";
                return(RedirectToPage("Index", new { permalink = ReferencedCalendarItem.UrlTitle, message = "Anmeldung gelöscht." }));
            }
            else
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
        }
Esempio n. 10
0
 ///<summary></summary>
 public FormRegistrationKeyEdit(RegistrationKey pRegistrationKey)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     registrationKey = pRegistrationKey;
 }
Esempio n. 11
0
        public void DataBind()
        {
            foreach (UIElement child in LayoutRoot.Children)
            {
                TextBox tbx = child as TextBox;
                if (tbx != null)
                {
                    tbx.Text = string.Empty;
                }
            }

            if (field == null)
            {
                throw new InvalidOperationException("Field property must be set to a valid SudokuField before databinding.");
            }
            datasource = field.GetData();
            if (datasource != null)
            {
                contentType          = field.ContentType;
                field.Updated       += new SudokuField.UpdateEvent(field_Updated);
                field.PuzzleSolved  += new SudokuField.OnPuzzleSolved(field_PuzzleSolved);
                field.StatusChanged += new SudokuField.OnStatusChanged(field_StatusChanged);

                foreach (UIElement child in LayoutRoot.Children)
                {
                    TextBox tbx = child as TextBox;
                    if (tbx != null)
                    {
                        RegistrationKey key = (RegistrationKey)tbx.Tag;
                        tbx.Text = GetDisplayValue(datasource[key.RowIndex, key.ColumnIndex].Value);
                        if (datasource[key.RowIndex, key.ColumnIndex].Given)
                        {
                            tbx.Background = new SolidColorBrush(Colors.Green);
                            tbx.Style      = styles[textBoxStyle];
                        }
                        else
                        {
                            //LinearGradientBrush brush = new LinearGradientBrush();
                            //GradientStop stop = new GradientStop();
                            //stop.Color = Color.FromArgb(255, 66, 113, 131);
                            //stop.Offset = 0;
                            //brush.GradientStops.Add(stop);
                            //stop = new GradientStop();
                            //stop.Color = Color.FromArgb(255, 76, 138, 168);
                            //stop.Offset = 0;
                            //brush.GradientStops.Add(stop);
                            //tbx.Background = brush;
                            //tbx.Style = (Style)Application.Current.Resources[_cellStyle];
                            tbx.Style = styles[textBoxStyle];

                            //tbx.Background = new SolidColorBrush(Colors.LightGray);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        private void RegisterTypeAs(Type implementationType, Type interfaceType, string name)
        {
            var registrationKey = new RegistrationKey(interfaceType, name);

            AssertNotResolved(registrationKey);

            ClearRegistrations(registrationKey);

            AddRegistration(registrationKey, new TypeRegistration(implementationType));
        }
Esempio n. 13
0
        ///<summary>Updates the given key data to the database.</summary>
        public static void Update(RegistrationKey registrationKey)
        {
            string command = "UPDATE registrationkey SET "
                             + "PatNum='" + POut.PInt(registrationKey.PatNum) + "',"
                             + "RegKey='" + POut.PString(registrationKey.RegKey) + "',"
                             + "Note='" + POut.PString(registrationKey.Note) + "'"
                             + " WHERE RegistrationKeyNum='" + POut.PInt(registrationKey.RegistrationKeyNum) + "'";

            General.NonQ(command);
        }
Esempio n. 14
0
        private void gridSubs_CellClick(object sender, UI.ODGridClickEventArgs e)
        {
            butAddJob.Text = "Add Job";          //Always reset
            if (e.Row == -1 || gridSubs.SelectedIndices.Length != 1)
            {
                bugSubmissionControl.ClearCustomerInfo();
                _subCur            = null;
                labelDateTime.Text = "";
                labelHashNum.Text  = "";
                bugSubmissionControl.SetTextDevNoteEnabled(false);
                return;
            }
            bugSubmissionControl.SetTextDevNoteEnabled(true);
            _subCur = ((List <BugSubmission>)gridSubs.ListGridRows[e.Row].Tag)[0];
            if (_dictPatients.ContainsKey(_subCur.RegKey))
            {
                _patCur = _dictPatients[_subCur.RegKey];
            }
            else
            {
                try {
                    RegistrationKey key = RegistrationKeys.GetByKey(_subCur.RegKey);
                    _patCur = Patients.GetPat(key.PatNum);
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    _patCur = new Patient();                  //Just in case, needed mostly for debug.
                }
                _dictPatients.Add(_subCur.RegKey, _patCur);
            }
            List <BugSubmission> listSubs = _listAllSubs;

            if (comboGrouping.SelectedIndex.In(1, 2, 3, 4, 5))
            {
                listSubs = ((List <BugSubmission>)gridSubs.ListGridRows[gridSubs.GetSelectedIndex()].Tag);
            }
            butAddJob.Tag = null;
            bugSubmissionControl.RefreshData(_dictPatients, comboGrouping.SelectedIndex, listSubs);          //New selelction, refresh control data.
            bugSubmissionControl.RefreshView(_subCur);
            labelDateTime.Text = POut.DateT(_subCur.SubmissionDateTime);
            labelHashNum.Text  = POut.Long(_subCur.BugSubmissionHashNum);
            if (_subCur.BugId != 0)
            {
                List <JobLink> listJobLink = _listJobLinks.Where(x => x.FKey == _subCur.BugId).ToList();
                if (listJobLink.Count == 1)
                {
                    butAddJob.Text = "View Job";
                    butAddJob.Tag  = listJobLink.First();
                }
            }
            if (_viewMode.In(FormBugSubmissionMode.SelectionMode, FormBugSubmissionMode.ValidationMode))
            {
                butAddJob.Text = "OK";
            }
        }
Esempio n. 15
0
        private void SaveTemplate()
        {
            IsolatedStorageFileStream stream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile("template");

            int rowNumber = 0;

            object[] newRows = new object[16];

            for (int i = 0; i < 16; i++)
            {
                int      columnNumber = 0;
                object[] newCells     = new object[16];
                if (sections[i] != null)
                {
                    foreach (Rectangle cell in sections[i])
                    {
                        RegistrationKey key     = (RegistrationKey)cell.Tag;
                        XElement        newCell = new XElement("Cell");
                        newCell.SetAttributeValue("Row", key.RowIndex.ToString());
                        newCell.SetAttributeValue("Column", key.ColumnIndex.ToString());
                        //newCell.SetAttributeValue("Section", cell.Text);
                        newCells[columnNumber] = newCell;

                        columnNumber++;
                    }
                }
                XElement newRow = new XElement("Row", newCells);
                newRow.SetAttributeValue("Number", rowNumber.ToString());
                newRows[rowNumber] = newRow;

                rowNumber++;
            }


            XElement newValues = new XElement("cellDefinitions", newRows);

            using (StreamWriter wr = new StreamWriter(stream))
            {
                try
                {
                    wr.WriteLine(newValues.ToString());
                    wr.Close();
                }
                catch (IOException)
                {
                    //TODO: errorhandling implementeren
                    //TODO: methods van commentaar voorzien
                }
                finally
                {
                    wr.Close();
                }
            }
        }
Esempio n. 16
0
        void field_Updated(object sender)
        {
            SudokuCell      cell     = (SudokuCell)sender;
            RegistrationKey key      = cell.Key;
            TextBox         output   = controls[key.RowIndex, key.ColumnIndex];
            int             value    = datasource[key.RowIndex, key.ColumnIndex].Value;
            string          text     = GetDisplayValue(value);
            SetTextCallback callback = new SetTextCallback(this.SetText);

            output.Dispatcher.BeginInvoke(callback, new object[] { output, text });
        }
Esempio n. 17
0
        private object ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
        {
            if (keyToResolve.Type.IsPrimitive || keyToResolve.Type == typeof(string) || keyToResolve.Type.IsValueType)
            {
                throw new ObjectContainerException("Primitive types or structs cannot be resolved: " + keyToResolve.Type.FullName, resolutionPath);
            }

            var registrationResult = GetRegistrationResult(keyToResolve) ?? new TypeRegistration(keyToResolve.Type);

            return(registrationResult.Resolve(this, keyToResolve, resolutionPath));
        }
Esempio n. 18
0
            public object Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
            {
                var obj = container.InvokeFactoryDelegate(factoryDelegate, resolutionPath, keyToResolve);

                if (dispose && obj is IDisposable && !container.disposableFactoryObjects.Contains(obj))
                {
                    container.disposableFactoryObjects.Add(obj as IDisposable);
                }

                return(obj);
            }
Esempio n. 19
0
            protected override object ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
            {
                var result = ExecuteWithLock(syncRoot, () => container.GetPooledObject(keyToResolve), () =>
                {
                    var obj = container.InvokeFactoryDelegate(factoryDelegate, resolutionPath, keyToResolve);
                    container.objectPool.Add(keyToResolve, obj);
                    return(obj);
                }, resolutionPath);

                return(result);
            }
Esempio n. 20
0
            public object Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
            {
                var obj       = container.InvokeFactoryDelegate(factoryDelegate, resolutionPath, keyToResolve);
                var objectKey = new RegistrationKey(obj.GetType(), keyToResolve.Name);

                if (dispose)
                {
                    container.objectPool.Add(objectKey, obj);
                }
                return(obj);
            }
Esempio n. 21
0
            protected override object ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
            {
                var obj = container.GetPooledObject(keyToResolve);

                if (obj == null)
                {
                    obj = container.InvokeFactoryDelegate(factoryDelegate, resolutionPath, keyToResolve);
                    container.objectPool.Add(keyToResolve, obj);
                }
                return(obj);
            }
Esempio n. 22
0
            private Type GetTypeToConstruct(RegistrationKey keyToResolve)
            {
                var targetType = implementationType;

                if (targetType.IsGenericTypeDefinition)
                {
                    var typeArgs = keyToResolve.Type.GetGenericArguments();
                    targetType = targetType.MakeGenericType(typeArgs);
                }
                return(targetType);
            }
Esempio n. 23
0
        private object CreateObjectFor(RegistrationKey keyToResolve, IEnumerable <Type> resolutionPath)
        {
            if (keyToResolve.Type.IsPrimitive || keyToResolve.Type == typeof(string))
            {
                throw new ObjectContainerException("Primitive types cannot be resolved: " + keyToResolve.Type.FullName, resolutionPath);
            }

            var registrationResult = GetRegistrationResult(keyToResolve) ?? new TypeRegistration(keyToResolve.Type);

            return(registrationResult.Resolve(this, keyToResolve, resolutionPath));
        }
Esempio n. 24
0
        public override bool Equals(object obj)
        {
            RegistrationEntryKey rhs = obj as RegistrationEntryKey;

            if (rhs == null)
            {
                return(false);
            }

            return((RegistrationKey.Equals(rhs.RegistrationKey)) && (Version == rhs.Version));
        }
Esempio n. 25
0
            private ResolutionList(RegistrationKey currentRegistrationKey, Type currentResolvedType, ResolutionList nextNode)
            {
                if (nextNode == null)
                {
                    throw new ArgumentNullException("nextNode");
                }

                this.currentRegistrationKey = currentRegistrationKey;
                this.currentResolvedType    = currentResolvedType;
                this.nextNode = nextNode;
            }
Esempio n. 26
0
        private object GetPooledObject(RegistrationKey pooledObjectKey)
        {
            object obj;

            if (GetObjectFromPool(pooledObjectKey, out obj))
            {
                return(obj);
            }

            return(null);
        }
Esempio n. 27
0
        private object Resolve(Type typeToResolve, ResolutionList resolutionPath, string name)
        {
            AssertNotDisposed();

            var keyToResolve = new RegistrationKey(typeToResolve, name);

            var resolvedObject = resolvedObjects.GetOrAdd(
                keyToResolve,
                key => ResolveObject(key, resolutionPath));

            return(resolvedObject);
        }
Esempio n. 28
0
        public bool IsRegistered <T>(string name)
        {
            Type typeToResolve = typeof(T);

            var keyToResolve = new RegistrationKey(typeToResolve, name);

            if (registrations.ContainsKey(keyToResolve))
            {
                return(true);
            }
            return(baseContainer != null && baseContainer.IsRegistered <T>(name));
        }
Esempio n. 29
0
 ///<summary>Returns true if Update(RegistrationKey,RegistrationKey) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(RegistrationKey registrationKey, RegistrationKey oldRegistrationKey)
 {
     if (registrationKey.PatNum != oldRegistrationKey.PatNum)
     {
         return(true);
     }
     if (registrationKey.RegKey != oldRegistrationKey.RegKey)
     {
         return(true);
     }
     if (registrationKey.Note != oldRegistrationKey.Note)
     {
         return(true);
     }
     if (registrationKey.DateStarted.Date != oldRegistrationKey.DateStarted.Date)
     {
         return(true);
     }
     if (registrationKey.DateDisabled.Date != oldRegistrationKey.DateDisabled.Date)
     {
         return(true);
     }
     if (registrationKey.DateEnded.Date != oldRegistrationKey.DateEnded.Date)
     {
         return(true);
     }
     if (registrationKey.IsForeign != oldRegistrationKey.IsForeign)
     {
         return(true);
     }
     if (registrationKey.UsesServerVersion != oldRegistrationKey.UsesServerVersion)
     {
         return(true);
     }
     if (registrationKey.IsFreeVersion != oldRegistrationKey.IsFreeVersion)
     {
         return(true);
     }
     if (registrationKey.IsOnlyForTesting != oldRegistrationKey.IsOnlyForTesting)
     {
         return(true);
     }
     if (registrationKey.VotesAllotted != oldRegistrationKey.VotesAllotted)
     {
         return(true);
     }
     if (registrationKey.IsResellerCustomer != oldRegistrationKey.IsResellerCustomer)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 30
0
        private IStrategyRegistration RegisterTypeAs(Type implementationType, Type interfaceType, string name)
        {
            var registrationKey = new RegistrationKey(interfaceType, name);

            AssertNotResolved(registrationKey);

            ClearRegistrations(registrationKey);
            var typeRegistration = new TypeRegistration(implementationType);

            AddRegistration(registrationKey, typeRegistration);

            return(typeRegistration);
        }
Esempio n. 31
0
        private void AddRegistration(RegistrationKey key, IRegistration registration)
        {
            registrations[key] = registration;

            if (key.Name != null)
            {
                var dictKey = CreateNamedInstanceDictionaryKey(key.Type);
                if (!registrations.ContainsKey(dictKey))
                {
                    registrations[dictKey] = new NamedInstanceDictionaryRegistration();
                }
            }
        }
Esempio n. 32
0
        public void GetHashCodeIgnoresCaseAndUsesNormalized(string idA, string idB, bool expectedEquals)
        {
            // Arrange
            var a = new RegistrationKey(idA);
            var b = new RegistrationKey(idB);

            // Act
            var hashCodeA = a.GetHashCode();
            var hashCodeB = b.GetHashCode();

            // Assert
            Assert.Equal(hashCodeA, hashCodeB);
        }
Esempio n. 33
0
        public void EqualsIgnoresCase(string idA, string idB, bool expectedEquals)
        {
            // Arrange
            var a = new RegistrationKey(idA);
            var b = new RegistrationKey(idB);

            // Act
            var actualEqualsA = a.Equals(b);
            var actualEqualsB = b.Equals(a);

            // Assert
            Assert.Equal(expectedEquals, actualEqualsA);
            Assert.Equal(expectedEquals, actualEqualsB);
        }
Esempio n. 34
0
        private object Resolve(Type typeToResolve, ResolutionList resolutionPath, string name)
        {
            AssertNotDisposed();

            var    keyToResolve   = new RegistrationKey(typeToResolve, name);
            object resolvedObject = ResolveObject(keyToResolve, resolutionPath);

            if (!resolvedKeys.Contains(keyToResolve))
            {
                resolvedKeys.Add(keyToResolve);
            }
            Debug.Assert(typeToResolve.IsInstanceOfType(resolvedObject));
            return(resolvedObject);
        }
Esempio n. 35
0
        public void RegisterInstanceAs(object instance, Type interfaceType, string name = null, bool dispose = false)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            var registrationKey = new RegistrationKey(interfaceType, name);

            AssertNotResolved(registrationKey);

            ClearRegistrations(registrationKey);
            AddRegistration(registrationKey, new InstanceRegistration(instance));
            objectPool[new RegistrationKey(instance.GetType(), name)] = GetPoolableInstance(instance, dispose);
        }
        public void RegistrationKey_is_equal()
        {
            var key1 = new RegistrationKey(typeof(IFoo));
            var key2 = new RegistrationKey(typeof(IFoo));

            Assert.AreEqual(key1, key2);
            Assert.AreNotSame(key1, key2);
            Assert.IsTrue(key1 == key2);
            Assert.IsTrue(key1.Equals(key2));

            var dic = new Dictionary<RegistrationKey, object>();
            dic.Add(key1, "");

            Assert.IsTrue(dic.ContainsKey(key1));
            Assert.IsTrue(dic.ContainsKey(key2));
        }
Esempio n. 37
0
 public void Register(Type handlertype, Type messagetype, Action<object, object,IParameterResolver> handle)
 {
     var key = new RegistrationKey(handlertype, messagetype);
     if (Handlers.ContainsKey(key))
     {
         var oldhandle = Handlers[key];
         Handlers[key] = (instance, message,pr) =>
         {
             oldhandle(instance, message,pr);
             handle(instance, message,pr);
         };
     }
     else
     {
         Handlers.Add(key, handle);
     }
 }
Esempio n. 38
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<RegistrationKey> TableToList(DataTable table){
			List<RegistrationKey> retVal=new List<RegistrationKey>();
			RegistrationKey registrationKey;
			for(int i=0;i<table.Rows.Count;i++) {
				registrationKey=new RegistrationKey();
				registrationKey.RegistrationKeyNum= PIn.Long  (table.Rows[i]["RegistrationKeyNum"].ToString());
				registrationKey.PatNum            = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				registrationKey.RegKey            = PIn.String(table.Rows[i]["RegKey"].ToString());
				registrationKey.Note              = PIn.String(table.Rows[i]["Note"].ToString());
				registrationKey.DateStarted       = PIn.Date  (table.Rows[i]["DateStarted"].ToString());
				registrationKey.DateDisabled      = PIn.Date  (table.Rows[i]["DateDisabled"].ToString());
				registrationKey.DateEnded         = PIn.Date  (table.Rows[i]["DateEnded"].ToString());
				registrationKey.IsForeign         = PIn.Bool  (table.Rows[i]["IsForeign"].ToString());
				registrationKey.UsesServerVersion = PIn.Bool  (table.Rows[i]["UsesServerVersion"].ToString());
				registrationKey.IsFreeVersion     = PIn.Bool  (table.Rows[i]["IsFreeVersion"].ToString());
				registrationKey.IsOnlyForTesting  = PIn.Bool  (table.Rows[i]["IsOnlyForTesting"].ToString());
				registrationKey.VotesAllotted     = PIn.Int   (table.Rows[i]["VotesAllotted"].ToString());
				registrationKey.IsResellerCustomer= PIn.Bool  (table.Rows[i]["IsResellerCustomer"].ToString());
				retVal.Add(registrationKey);
			}
			return retVal;
		}
 public RegistrationEntryKey(RegistrationKey registrationKey, string version)
 {
     RegistrationKey = registrationKey;
     Version = version;
 }
Esempio n. 40
0
		///<summary>Updates one RegistrationKey in the database.</summary>
		public static void Update(RegistrationKey registrationKey){
			string command="UPDATE registrationkey SET "
				+"PatNum            =  "+POut.Long  (registrationKey.PatNum)+", "
				+"RegKey            = '"+POut.String(registrationKey.RegKey)+"', "
				+"Note              = '"+POut.String(registrationKey.Note)+"', "
				+"DateStarted       =  "+POut.Date  (registrationKey.DateStarted)+", "
				+"DateDisabled      =  "+POut.Date  (registrationKey.DateDisabled)+", "
				+"DateEnded         =  "+POut.Date  (registrationKey.DateEnded)+", "
				+"IsForeign         =  "+POut.Bool  (registrationKey.IsForeign)+", "
				+"UsesServerVersion =  "+POut.Bool  (registrationKey.UsesServerVersion)+", "
				+"IsFreeVersion     =  "+POut.Bool  (registrationKey.IsFreeVersion)+", "
				+"IsOnlyForTesting  =  "+POut.Bool  (registrationKey.IsOnlyForTesting)+", "
				+"VotesAllotted     =  "+POut.Int   (registrationKey.VotesAllotted)+", "
				+"IsResellerCustomer=  "+POut.Bool  (registrationKey.IsResellerCustomer)+" "
				+"WHERE RegistrationKeyNum = "+POut.Long(registrationKey.RegistrationKeyNum);
			Db.NonQ(command);
		}
Esempio n. 41
0
		///<summary>Updates one RegistrationKey in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(RegistrationKey registrationKey,RegistrationKey oldRegistrationKey){
			string command="";
			if(registrationKey.PatNum != oldRegistrationKey.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(registrationKey.PatNum)+"";
			}
			if(registrationKey.RegKey != oldRegistrationKey.RegKey) {
				if(command!=""){ command+=",";}
				command+="RegKey = '"+POut.String(registrationKey.RegKey)+"'";
			}
			if(registrationKey.Note != oldRegistrationKey.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(registrationKey.Note)+"'";
			}
			if(registrationKey.DateStarted != oldRegistrationKey.DateStarted) {
				if(command!=""){ command+=",";}
				command+="DateStarted = "+POut.Date(registrationKey.DateStarted)+"";
			}
			if(registrationKey.DateDisabled != oldRegistrationKey.DateDisabled) {
				if(command!=""){ command+=",";}
				command+="DateDisabled = "+POut.Date(registrationKey.DateDisabled)+"";
			}
			if(registrationKey.DateEnded != oldRegistrationKey.DateEnded) {
				if(command!=""){ command+=",";}
				command+="DateEnded = "+POut.Date(registrationKey.DateEnded)+"";
			}
			if(registrationKey.IsForeign != oldRegistrationKey.IsForeign) {
				if(command!=""){ command+=",";}
				command+="IsForeign = "+POut.Bool(registrationKey.IsForeign)+"";
			}
			if(registrationKey.UsesServerVersion != oldRegistrationKey.UsesServerVersion) {
				if(command!=""){ command+=",";}
				command+="UsesServerVersion = "+POut.Bool(registrationKey.UsesServerVersion)+"";
			}
			if(registrationKey.IsFreeVersion != oldRegistrationKey.IsFreeVersion) {
				if(command!=""){ command+=",";}
				command+="IsFreeVersion = "+POut.Bool(registrationKey.IsFreeVersion)+"";
			}
			if(registrationKey.IsOnlyForTesting != oldRegistrationKey.IsOnlyForTesting) {
				if(command!=""){ command+=",";}
				command+="IsOnlyForTesting = "+POut.Bool(registrationKey.IsOnlyForTesting)+"";
			}
			if(registrationKey.VotesAllotted != oldRegistrationKey.VotesAllotted) {
				if(command!=""){ command+=",";}
				command+="VotesAllotted = "+POut.Int(registrationKey.VotesAllotted)+"";
			}
			if(registrationKey.IsResellerCustomer != oldRegistrationKey.IsResellerCustomer) {
				if(command!=""){ command+=",";}
				command+="IsResellerCustomer = "+POut.Bool(registrationKey.IsResellerCustomer)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE registrationkey SET "+command
				+" WHERE RegistrationKeyNum = "+POut.Long(registrationKey.RegistrationKeyNum);
			Db.NonQ(command);
			return true;
		}