public override void Initialize(BacktestServerProxy.RobotContext grobotContext, 
     Contract.Util.BL.CurrentProtectedContext protectedContextx)
 {
     base.Initialize(grobotContext, protectedContextx);
     packers = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
     digitsDen = (int) Math.Pow(10, roundDigits);
 }
 public void InsertTest(Contract.CTestManager manager)
 {
     using (TestManagerDBContainer container = new TestManagerDBContainer())
     {
         int result = container.InsertTestManager(manager.Name, manager.Description, manager.NumberOfQuestions, manager.NumberOfQuestions, manager.TotalMarks, manager.GradeID, manager.Duration, manager.PassingMarks);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Constructor for the <c>ReadGraph</c> object. This is used
 /// to create graphs that are used for reading objects from the XML
 /// document. The specified strategy is used to acquire the names
 /// of the special attributes used during the serialization.
 /// </summary>
 /// <param name="contract">
 /// this is the name scheme used by the strategy
 /// </param>
 /// <param name="loader">
 /// this is the class loader to used for the graph
 /// </param>
 public ReadGraph(Contract contract, Loader loader) {
    this.refer = contract.getReference();
    this.mark = contract.getIdentity();
    this.length = contract.getLength();
    this.label = contract.getLabel();
    this.loader = loader;
 }
Beispiel #4
0
        public static bool NewContract(Contract Ct)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.ProxyCreationEnabled = false;
                db.Configuration.LazyLoadingEnabled = false;
                db.Contracts.Add(Ct);
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {
               
                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                File.WriteAllText("t.txt", ex.InnerException.InnerException.Message);
                e.UserDescription = "Error in Save Changed";
                if (ex.InnerException.InnerException.Message.Contains("Violation of PRIMARY KEY constraint 'PK_Contracts'. Cannot insert duplicate key in object 'dbo.Contracts'"))
                {
                    e.UserDescriptionArabic = "الموظف موجود عقده في المشروع مسبقا";

                }
                else
                    e.UserDescriptionArabic = e.OtherDescription;//"خطاء في اضافة البيانات";
               
                 throw e;
            }
        }
        public async Task CreateContract(CreateContractInputDto input)
        {
            //We can use Logger, it's defined in ApplicationService class.
            Logger.Info("Creating an contract for input: " + input);

            //Creating a new Task entity with given input's properties
            var contract = new Contract
            {
                Start = input.Start,
                State = ContractState.Active,
                Type = input.Type,
                BaseHourQtyPerMonth = input.BaseHourQtyPerMonth,
                BaseHourRatePerMonth = input.BaseHourRatePerMonth
                

            };
            if (input.Finish.HasValue) { contract.Finish = input.Finish; }

            
            contract.AccountId = input.AccountId;
            contract.Account = _accountRepository.Load((long)input.AccountId);
           

            //Saving entity with standard Insert method of repositories.
            await _contractRepository.InsertAsync(contract);
        }
Beispiel #6
0
        public static bool EditContract(Contract Ct)
        {
            try
            {
                db = new UcasProEntities();
                db.Configuration.LazyLoadingEnabled = false;
                db.Configuration.ProxyCreationEnabled = false;
                var q = db.Contracts.Where(p => p.ID == Ct.ID).SingleOrDefault();
                q.Employee_ID = Ct.Employee_ID;
                q.TotalSalary = Ct.TotalSalary;
                q.SelaryAmount = Ct.SelaryAmount;
                q.StartDate = Ct.StartDate;
                q.EndDate = Ct.EndDate;
                q.Status = Ct.Status;
                
                db.SaveChanges();
                return true;

            }
            catch (Exception ex)
            {


                Xprema.XpremaException e = new Xprema.XpremaException();
                e.CodeNumber = 6;
                e.OtherDescription = ex.InnerException.InnerException.Message;
                e.UserDescription = "Error in Save Changed";
                e.UserDescriptionArabic = "خطاء في حفظ البيانات";
                throw e;
            }
        }
        public bool ProvisionSiteCollection(Contract.SharePointProvisioningData sharePointProvisioningData)
        {
            bool processed = false;
            try
            {
                SiteProvisioningBase siteToProvision = null;
                switch (sharePointProvisioningData.Template)
                {
                    case SiteProvisioningTypes.ContosoCollaboration:
                        siteToProvision = new ContosoCollaboration();
                        break;
                    case SiteProvisioningTypes.ContosoProject:
                        siteToProvision = new ContosoProject();
                        break;
                }

                siteToProvision.SharePointProvisioningData = sharePointProvisioningData;
                HookupAuthentication(siteToProvision);

                // Hookup class that will hold the on-prem overrides
                SiteProvisioningOnPremises spo = new SiteProvisioningOnPremises();
                siteToProvision.SiteProvisioningOnPremises = spo;

                // Provision the site collection
                processed = siteToProvision.Execute();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //log error
            }

            return processed;
        }
Beispiel #8
0
        public Contract.Search.SearchResultCollection ExecutePathologistSearch(Contract.Search.Search search)
        {
            YellowstonePathology.YpiConnect.Service.SearchGateway gateway = new YellowstonePathology.YpiConnect.Service.SearchGateway();
            YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection searchResults = null;

            switch (search.SearchType)
            {
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.PatientLastNameSearch:
                    searchResults = gateway.GetPathologistCasesByPatientLastName(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.PatientLastAndFirstNameSearch:
                    searchResults = gateway.GetPathologistCasesByPatientLastNameAndFirstName(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.RecentCases:
                    searchResults = gateway.GetPathologistRecentCases(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.DateOfBirth:
                    searchResults = gateway.GetPathologistCasesByPBirthDate(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.SocialSecurityNumber:
                    searchResults = gateway.GetPathologistCasesByPSSN(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.RecentCasesForFacilityId:
                    searchResults = gateway.GetRecentProfessionalCasesByFacilityId(search);
                    break;
            }

            if (searchResults == null) searchResults = new Contract.Search.SearchResultCollection();
            return searchResults;
        }
 private void WriteAssignments(Contract contract, IndentedTextWriter writer)
 {
     foreach (Member member in contract.Members)
     {
         writer.WriteLine("{0} = {1};", member.Name, GeneratorUtil.ParameterCase(member.Name));
     }
 }
 private void btnNewContract_Click_1(object sender, RoutedEventArgs e)
 {
     Contract nContract = new Contract();
     nContract.CompanyId = company.Id;
     saveUpdateContract(nContract);
     loadContracts();
 }
Beispiel #11
0
        public Contract.Search.SearchResultCollection ExecuteClientSearch(Contract.Search.Search search)
        {
            YellowstonePathology.YpiConnect.Service.SearchGateway gateway = new YellowstonePathology.YpiConnect.Service.SearchGateway();
            YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection searchResults = null;

            switch (search.SearchType)
            {
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.PatientLastNameSearch:
                    searchResults = gateway.GetClientCasesByPatientLastName(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.PatientLastAndFirstNameSearch:
                    searchResults = gateway.GetClientCasesByPatientLastNameAndFirstName(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.RecentCases:
                    searchResults = gateway.GetClientRecentCases(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.NotDownloaded: //Not Downloaded is Depricated SH 5/17/2010
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.NotAcknowledged:
                    searchResults = gateway.GetClientCasesNotAcknowledged(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.DateOfBirth:
                    searchResults = gateway.GetClientCasesByPBirthDate(search);
                    break;
                case YellowstonePathology.YpiConnect.Contract.Search.SearchTypeEnum.SocialSecurityNumber:
                    searchResults = gateway.GetClientCasesByPSSN(search);
                    break;
            }

            if (searchResults == null) searchResults = new Contract.Search.SearchResultCollection();
            return searchResults;
        }
Beispiel #12
0
        public async Task<IHttpActionResult> PutContract(int id, Contract contract)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != contract.Id)
            {
                return BadRequest();
            }
            using (var transaction = db.Database.BeginTransaction())
            {
                var origin = db.Contracts.Find(contract.Id);
                db.Entry<Contract>(origin).Collection(c => c.AppartmentOwners).Load();

                db.Changes.AddRange(Helper.Logger.ChangeRecords<Contract>(origin, contract, RequestContext.Principal.Identity.Name));
                var added = contract.AppartmentOwners.Except(origin.AppartmentOwners.ToList(), new AppartmentOwnerComparator());
                var deleted = origin.AppartmentOwners.ToList().Except(contract.AppartmentOwners, new AppartmentOwnerComparator());
                db.AppartmentOwners.RemoveRange(deleted);
                foreach (var ao in added)
                {
                    ao.ContractId = contract.Id;
                    db.AppartmentOwners.Add(ao);
                }
                db.Entry<Contract>(origin).State = EntityState.Detached;
                await db.SaveChangesAsync();
                foreach (var ao in contract.AppartmentOwners)
                {
                    var aoindb = db.AppartmentOwners.Find(ao.Id);
                    aoindb.ShowAsOwner = ao.ShowAsOwner;
                    aoindb.ShowOnCert = ao.ShowOnCert;
                    db.Entry<AppartmentOwner>(aoindb).State = EntityState.Modified;
                }
               
                contract.AppartmentOwners = null;
                db.Entry<Contract>(contract).State = EntityState.Modified;
               
                try
                {
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContractExists(id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                transaction.Commit();
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public ContractView(Contract contract)
        {
            InitializeComponent();

            _activeContract = contract;
            _repository = new DataRepository();

            PopulateFields(contract);
            InitializeHandlers();
        }
 public ActionResult Edit(Contract contract)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contract).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(contract);
 }
Beispiel #15
0
        public DevContract(winStatusEnum status, Contract con = null)
        {
            InitializeComponent();
            if (con != null)
                m_contract = con;
            else
                m_contract = new Contract();

            SetFormStatus(status);
        }
        public int PutUserProfile(Contract.DataContract.User user)
        {
            Guid userId = ((NotenetIdentity)HttpContext.Current.User.Identity).UID;
            if (userId != user.userID)
            {
                return -1;//will not be stopped at exception
            }

            return (int)db.PutUserInfo(user.userID, user.Birthday, user.NickName, user.RealName, user.Email).FirstOrDefault();
        }
Beispiel #17
0
        public QuoteSubscription(IConnection connection, IIdsDispenser dispenser, IQuoteObserver observer, Contract contract)
        {
            CodeContract.Requires(connection != null);
            CodeContract.Requires(observer != null);
            CodeContract.Requires(dispenser != null);

            this.connection = connection;
            this.observer = observer;

            this.Subscribe(contract, dispenser);
        }
 private void PopulateFields(Contract contract)
 {
     //Populate all the onscreen controls with the relevant information of the contract
     lblLocation.Text = contract.StartSystem.SolarSystemDisplayName;
     lblDestination.Text = contract.EndSystem.SolarSystemDisplayName;
     lblStatus.Text = contract.Status;
     lblVolume.Text = contract.Volume.ToString("N") + " m3";
     lblExpires.Text = contract.Expiration.ToString();
     lblReward.Text = contract.Reward.ToString("N") + " ISK";
     lblCollateral.Text = contract.Collateral.ToString("N") + " ISK";
 }
Beispiel #19
0
        private void _ActivateListing(ref FormListing form, Contract contract)
        {
            if (form == null || form.IsDisposed) {
                form = new FormListing(contract);
                form.MdiParent = this;
            }

            form.WindowState = FormWindowState.Maximized;
            form.Show();
            form.Focus();
        }
        public ActionResult Create(Contract contract)
        {
            if (ModelState.IsValid)
            {
                db.Contracts.Add(contract);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(contract);
        }
Beispiel #21
0
 public void Check(Contract contract)
 {
     for (int i = 0; i < ScriptHashes.Length; i++)
     {
         if (ScriptHashes[i] == contract.ScriptHash)
         {
             completed[i] = contract.IsCompleted(signatures[i].Keys.ToArray());
             break;
         }
     }
 }
        public string FindMetadataEndpointAddress(Contract.DTO.ServiceLocation serviceLocation)
        {
            FunctionalErrorList errorList = new FunctionalErrorList();
            if (serviceLocation.Name == null || serviceLocation.Profile == null ||
                serviceLocation.Name == "" || serviceLocation.Profile == "")
            {
                errorList.Add(new FunctionalErrorDetail
                {
                    Message = "Name or Profile is null"
                });
                throw new FaultException<FunctionalErrorList>(errorList);
            }

            try
            {
                if (serviceLocation.Version == null)
                {
                    return _datamapper.FindMetadataEndpointAddress(serviceLocation.Name, serviceLocation.Profile);
                }
                return _datamapper.FindMetadataEndpointAddress(serviceLocation.Name, serviceLocation.Profile, serviceLocation.Version);
            }
            catch (MultipleRecordsFoundException ex)
            {
                errorList.Add(new FunctionalErrorDetail
                {
                    Message = ex.Message,
                    Data = ex.Data
                });
            }
            catch (NoRecordsFoundException ex)
            {
                errorList.Add(new FunctionalErrorDetail
                {
                    Message = ex.Message,
                    Data = ex.Data
                });
            }
            catch (VersionedRecordFoundException ex)
            {
                errorList.Add(new FunctionalErrorDetail
                {
                    Message = ex.Message,
                    Data = ex.Data
                });
            }

            if (errorList.HasErrors)
            {
                //throw new FunctionalException() { Errors = errorList };
                throw new FaultException<FunctionalErrorList>(errorList);
            }

            return null;
        }
        public RoutePlanner(Contract contract)
        {
            InitializeComponent();

            _activeContract = contract;
            _dataRepository = new DataRepository();
            _cacheManager = new OverrideCacheManager();
            _logger = NLog.LogManager.GetCurrentClassLogger();

            InitalizeHandlers();
            PopulateSearchForm();
        }
Beispiel #24
0
        private void Subscribe(Contract contract, IIdsDispenser dispenser)
        {
            this.requestId = dispenser.NextRequestId();

            this.subscriptions = new List<IDisposable>
            {
                this.connection.Subscribe((TickPriceMessage message) => message.RequestId == this.requestId,
                    this.OnTickPrice),
                this.connection.SubscribeForRequestErrors(this.requestId, this.OnError)
            };

            this.SendRequest(contract);
        }
        public MarketDepthSubscription(IConnection connection, IIdsDispenser dispenser, IMarketDepthObserver observer,
            Contract contract)
        {
            CodeContract.Requires(connection != null);
            CodeContract.Requires(dispenser != null);
            CodeContract.Requires(observer != null);

            this.connection = connection;
            this.observer = observer;
            this.marketDepthUpdatesDispatcher = new MarketDepthUpdatesDispatcher(observer);

            this.Subscribe(dispenser, contract);
        }
Beispiel #26
0
 public IEnumerable<Booking> BookingsByResource(Contract.TimeSlot timeSlot, int resourceId)
 {
     using (IDbConnection connection = OpenConnection())
     {
         var bookings = connection.Query<BookingPM>(
             string.Format(
     @"SELECT {0} FROM `bookings`
     WHERE `ResourceId` = @ResourceId
     AND `From` <= @To AND `To` >= @From;", SqlHelper.Columns(_bookingColumns)),
             new { ResourceId = resourceId, From = timeSlot.From, To = timeSlot.To });
         return bookings.Select(n => BookingPM.FromPM(n));
     }
 }
 public string SaveToDoItem(Contract.ToDoItemContract toDoItemContract)
 {
     try
     {
         ToDoItemEntityBuilder builder = new ToDoItemEntityBuilder();
         
         return ToDoItemService.Save(builder.Build(toDoItemContract));
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
 public Contract Create()
 {
     Contract newContract = new Contract
     {
         Name = GenerateRandomString(),
         Supplier = GenerateRandomString(),
         Purchaser = GenerateRandomString(),
     };
     int maxItems = random.Next(1, 5);
     for (int i = 0; i < maxItems; i++)
         newContract.Add(RandomStorableFactory());
     return newContract;
 }
        private void Subscribe(IIdsDispenser dispenser, Contract contract)
        {
            this.requestId = dispenser.NextRequestId();

            this.subscriptions = new List<IDisposable>
            {
                this.connection.Subscribe((MarketDepthMessage message) => message.RequestId == this.requestId,
                    this.OnMarketDepth),
                this.connection.SubscribeForRequestErrors(this.requestId, this.OnError)
            };

            this.SendRequest(contract, this.requestId);
        }
        public ContractFrm(Contract contract)
        {
            InitializeComponent();
            this.contract = contract;

            // this is a new contract
            if (contract.Id == 0)
            {
                // preselect start date
                dateStart.SelectedDate = DateTime.Today;
            }
            else
            {
                dateStart.SelectedDate = contract.StartDate;
                dateEnd.SelectedDate = contract.EndDate;
            }

            // set initial values
            if (contract.Number != 0)
                tboNumber.Text = contract.Number.ToString();

            // set combobox binding
            cboCompany.ItemsSource = Global.companies;
            cboCompany.DisplayMemberPath = "Name";
            cboCompany.SelectedValuePath = "id";

            cboContractFormula.ItemsSource = Global.contractFormula;
            cboContractFormula.DisplayMemberPath = "Description";
            cboContractFormula.SelectedValuePath = "id";

            if (!Global.user.IsAdmin)
                cboCompany.IsEnabled = false;

            // preselect company and formula
            if (contract.CompanyId != 0 && contract.ContractFormulaId != 0)
            {
                for (int i = 0; i < Global.companies.Count; i++)
                {
                    if (Global.companies[i].Id == contract.CompanyId)
                        cboCompany.SelectedIndex = i;
                }

                for (int i = 0; i < Global.contractFormula.Count; i++)
                {
                    if (Global.contractFormula[i].Id == contract.ContractFormulaId)
                        cboContractFormula.SelectedIndex = i;
                }
            }
        }
 public virtual string ToString()
 {
   Contract.Ensures(Contract.Result<string>() != null);
   return default(string);
 }
Beispiel #32
0
 public static string HexEscape(char character)
 {
     Contract.Ensures(Contract.Result <string>() != null);
     return(default(string));
 }
Beispiel #33
0
        public static String ExpandEnvironmentVariables(String name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            Contract.EndContractBlock();

            if (name.Length == 0)
            {
                return(name);
            }

            int           currentSize = 100;
            StringBuilder blob        = new StringBuilder(currentSize); // A somewhat reasonable default size

#if PLATFORM_UNIX                                                       // Win32Native.ExpandEnvironmentStrings isn't available
            int lastPos = 0, pos;
            while (lastPos < name.Length && (pos = name.IndexOf('%', lastPos + 1)) >= 0)
            {
                if (name[lastPos] == '%')
                {
                    string key   = name.Substring(lastPos + 1, pos - lastPos - 1);
                    string value = Environment.GetEnvironmentVariable(key);
                    if (value != null)
                    {
                        blob.Append(value);
                        lastPos = pos + 1;
                        continue;
                    }
                }
                blob.Append(name.Substring(lastPos, pos - lastPos));
                lastPos = pos;
            }
            blob.Append(name.Substring(lastPos));
#else
            int size;

            blob.Length = 0;
            size        = Win32Native.ExpandEnvironmentStrings(name, blob, currentSize);
            if (size == 0)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            while (size > currentSize)
            {
                currentSize   = size;
                blob.Capacity = currentSize;
                blob.Length   = 0;

                size = Win32Native.ExpandEnvironmentStrings(name, blob, currentSize);
                if (size == 0)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }
            }
#endif // PLATFORM_UNIX

            return(blob.ToString());
        }
 protected object MemberwiseClone()
 {
   Contract.Ensures(Contract.Result<object>().GetType().Equals(this.GetType()));
   Contract.Ensures(Contract.Result<object>() != null);
   return default(object);
 }
Beispiel #35
0
 public Uri(string uriString)
 {
     Contract.Requires(uriString != null);
 }
Beispiel #36
0
        private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param, Type type, bool inherit)
        {
            Contract.Requires(param != null);

            // For ParameterInfo's we need to make sure that we chain through all the MethodInfo's in the inheritance chain that
            // have this ParameterInfo defined. .We pick up all the CustomAttributes for the starting ParameterInfo. We need to pick up only attributes
            // that are marked inherited from the remainder of the MethodInfo's in the inheritance chain.
            // For MethodInfo's on an interface we do not do an inheritance walk so the default ParameterInfo attributes are returned.
            // For MethodInfo's on a class we walk up the inheritance chain but do not look at the MethodInfo's on the interfaces that the
            // class inherits from and return the respective ParameterInfo attributes

            List <Type> disAllowMultiple = new List <Type>();

            Object[] objAttr;

            if (type == null)
            {
                type = typeof(Attribute);
            }

            objAttr = param.GetCustomAttributes(type, false);

            for (int i = 0; i < objAttr.Length; i++)
            {
                Type objType = objAttr[i].GetType();
                AttributeUsageAttribute attribUsage = InternalGetAttributeUsage(objType);
                if (attribUsage.AllowMultiple == false)
                {
                    disAllowMultiple.Add(objType);
                }
            }

            // Get all the attributes that have Attribute as the base class
            Attribute[] ret = null;
            if (objAttr.Length == 0)
            {
                ret = CreateAttributeArrayHelper(type, 0);
            }
            else
            {
                ret = (Attribute[])objAttr;
            }

            if (param.Member.DeclaringType == null) // This is an interface so we are done.
            {
                return(ret);
            }

            if (!inherit)
            {
                return(ret);
            }

            ParameterInfo baseParam = GetParentDefinition(param);

            while (baseParam != null)
            {
                objAttr = baseParam.GetCustomAttributes(type, false);

                int count = 0;
                for (int i = 0; i < objAttr.Length; i++)
                {
                    Type objType = objAttr[i].GetType();
                    AttributeUsageAttribute attribUsage = InternalGetAttributeUsage(objType);

                    if ((attribUsage.Inherited) && (disAllowMultiple.Contains(objType) == false))
                    {
                        if (attribUsage.AllowMultiple == false)
                        {
                            disAllowMultiple.Add(objType);
                        }
                        count++;
                    }
                    else
                    {
                        objAttr[i] = null;
                    }
                }

                // Get all the attributes that have Attribute as the base class
                Attribute[] attributes = CreateAttributeArrayHelper(type, count);

                count = 0;
                for (int i = 0; i < objAttr.Length; i++)
                {
                    if (objAttr[i] != null)
                    {
                        attributes[count] = (Attribute)objAttr[i];
                        count++;
                    }
                }

                Attribute[] temp = ret;
                ret = CreateAttributeArrayHelper(type, temp.Length + count);
                Array.Copy(temp, ret, temp.Length);

                int offset = temp.Length;

                for (int i = 0; i < attributes.Length; i++)
                {
                    ret[offset + i] = attributes[i];
                }

                baseParam = GetParentDefinition(baseParam);
            }

            return(ret);
        }
Beispiel #37
0
 internal unsafe static void Memcpy(byte *dest, byte *src, int len)
 {
     Contract.Assert(len >= 0, "Negative length in memcopy!");
     Memmove(dest, src, (uint)len);
 }
Beispiel #38
0
        public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (flds == null)
            {
                throw new ArgumentNullException(nameof(flds));
            }
            Contract.EndContractBlock();
            if (flds.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));
            }

            IntPtr[] fields = new IntPtr[flds.Length];
            // For proper handling of Nullable<T> don't change GetType() to something like 'IsAssignableFrom'
            // Currently we can't make a TypedReference to fields of Nullable<T>, which is fine.
            RuntimeType targetType = (RuntimeType)target.GetType();

            for (int i = 0; i < flds.Length; i++)
            {
                RuntimeFieldInfo field = flds[i] as RuntimeFieldInfo;
                if (field == null)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));
                }

                if (field.IsInitOnly || field.IsStatic)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
                }

                if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal()))
                {
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));
                }

                RuntimeType fieldType = (RuntimeType)field.FieldType;
                if (fieldType.IsPrimitive)
                {
                    throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
                }

                if (i < (flds.Length - 1) && !fieldType.IsValueType)
                {
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
                }

                fields[i]  = field.FieldHandle.Value;
                targetType = fieldType;
            }

            TypedReference result = new TypedReference();

            // reference to TypedReference is banned, so have to pass result as pointer
            unsafe
            {
                InternalMakeTypedReference(&result, target, fields, targetType);
            }
            return(result);
        }
 public Type GetType()
 {
   Contract.Ensures(Contract.Result<Type>() != null);
   return default(Type);
 }
Beispiel #40
0
 public Uri MakeRelativeUri(Uri uri)
 {
     Contract.Requires(uri != null);
     Contract.Ensures(Contract.Result <Uri>() != null);
     return(default(Uri));
 }
Beispiel #41
0
 public Uri(Uri baseUri, string relativeUri, bool dontEscape)
 {
     Contract.Requires(baseUri != null);
     Contract.Requires(relativeUri != null);
 }
Beispiel #42
0
 public Uri(Uri baseUri, string relativeUri)
 {
     Contract.Requires(baseUri != null);
     Contract.Requires(relativeUri != null);
 }
Beispiel #43
0
 public Uri(string uriString, bool dontEscape)
 {
     Contract.Requires(uriString != null);
 }
Beispiel #44
0
        public string GetLeftPart(UriPartial part)
        {
            Contract.Ensures(Contract.Result <string>() != null);

            return(default(string));
        }
Beispiel #45
0
        [System.Security.SecurityCritical]  // auto-generated
        internal unsafe static int IndexOfByte(byte *src, byte value, int index, int count)
        {
            Contract.Assert(src != null, "src should not be null");

            byte *pByte = src + index;

            // Align up the pointer to sizeof(int).
            while (((int)pByte & 3) != 0)
            {
                if (count == 0)
                {
                    return(-1);
                }
                else if (*pByte == value)
                {
                    return((int)(pByte - src));
                }

                count--;
                pByte++;
            }

            // Fill comparer with value byte for comparisons
            //
            // comparer = 0/0/value/value
            uint comparer = (((uint)value << 8) + (uint)value);

            // comparer = value/value/value/value
            comparer = (comparer << 16) + comparer;

            // Run through buffer until we hit a 4-byte section which contains
            // the byte we're looking for or until we exhaust the buffer.
            while (count > 3)
            {
                // Test the buffer for presence of value. comparer contains the byte
                // replicated 4 times.
                uint t1 = *(uint *)pByte;
                t1 = t1 ^ comparer;
                uint t2 = 0x7efefeff + t1;
                t1 = t1 ^ 0xffffffff;
                t1 = t1 ^ t2;
                t1 = t1 & 0x81010100;

                // if t1 is zero then these 4-bytes don't contain a match
                if (t1 != 0)
                {
                    // We've found a match for value, figure out which position it's in.
                    int foundIndex = (int)(pByte - src);
                    if (pByte[0] == value)
                    {
                        return(foundIndex);
                    }
                    else if (pByte[1] == value)
                    {
                        return(foundIndex + 1);
                    }
                    else if (pByte[2] == value)
                    {
                        return(foundIndex + 2);
                    }
                    else if (pByte[3] == value)
                    {
                        return(foundIndex + 3);
                    }
                }

                count -= 4;
                pByte += 4;
            }

            // Catch any bytes that might be left at the tail of the buffer
            while (count > 0)
            {
                if (*pByte == value)
                {
                    return((int)(pByte - src));
                }

                count--;
                pByte++;
            }

            // If we don't have a match return -1;
            return(-1);
        }