コード例 #1
0
 public MyCompany(MicrosoftBC.Company MCompany)
 {
     this._MCompany = MCompany;
 }
コード例 #2
0
        /// <summary>
        /// Add one Company (a type from one of the OData clients) to a Dictionary of MyCompany objects.
        /// Only one of the "Comp" parameters should be non-null.
        /// </summary>
        /// <param name="companies">the Dictionary to add to</param>
        /// <param name="MComp">a Company to add, from the Microsoft BC API Client</param>
        /// <param name="EComp">a Company to add, from the Entocare BC API Client</param>
        private void AddToMyCompanyDictionary(Dictionary <string, MyCompany> companies, MicrosoftBC.Company MComp = null, Entocare.NAV.Company EComp = null)
        {
            //Cast the received Company "subtype" to the MyCompany "supertype"... sort of
            MyCompany comp = null;

            if (MComp != null)
            {
                comp = new MyCompany(MComp);
            }
            else if (EComp != null)
            {
                comp = new MyCompany(EComp);
            }
            else
            {
                throw new InvalidOperationException("Error building up the Company Dictionary: one of the two Company subtypes should be supplied.");
            }

            //Add it to the Dictionary
            if (!companies.ContainsKey(comp.Name))
            {
                companies.Add(comp.Name, comp);
            }
            else
            {
                throw new InvalidOperationException("Company name " + comp.Name + " is not unique within this BC instance (Sandbox=" + Debug + ")");
            }
        }